Git Basics for DevOps Beginners
Read this guide in: English · मराठी · हिंदी
Why do we need Git? Because there is a real problem between developers and operations when history is a zip. Developers change code on the laptop. Operations — the employee on the server side — copies “whatever build arrived last.” Friday night nobody knows which file is live. Git joins both sides: every save is a commit with who, when and why, then git push puts the same history on GitHub.
Friends, do not start with twenty Git commands. First understand the mystery-build fight. Then add, commit, push will feel natural.
Quick answer
Hold this vertical picture:
- Developer — edits code on the laptop.
- Operations — server-side employee who must put a known version on the server.
- The problem — WhatsApp/email zips; no author; “which build is live?”
- Git — commits replace mystery zips; push shares one history with the team.
- Pocket verbs:
git add→git commit→git push.
Language: English · मराठी · हिंदी
Why do we need Git?
Developers and operations both care about the product, but without shared history they fight:
- Developers finish a change and say “done.”
- Operations on the server side needs a file they can trust — not three zips with different names.
- When production breaks, both need: who changed what, and when?
That is why beginners learn Git before pipelines.
What does operations have to do with Git?
- Operations is the server-side employee (or team).
- Their day includes deploy, restart, logs, rollback.
- Without Git they guess which zip to copy. With Git they deploy a known commit.
What is the problem? Suppose we are…
Suppose we are building Instagram (like updates)
Suppose your team ships Instagram-style profile badges.
- Monday — developer A emails
profile-final.zip. - Developer B also edits and WhatsApps
profile-FINAL-v2.zip. - Wednesday — operations (server-side) copies “the latest” by guesswork to production.
- Friday night — profile page wrong. “Worked on my laptop.” Nobody knows which zip is live.
Suppose we are working at Netflix and we are giving updates
Suppose Netflix pushes many small home-screen fixes a week. If history is only zip names in chat, operations cannot roll back to “Tuesday’s good build” with confidence.
Suppose you are working in Infosys on a client project
Suppose two Infosys developers email builds to the client operations team. Client asks: which attachment is approved? Without Git + review, release day is a war room.
Git path: edit in the working tree, git add to stage, git commit to save a snapshot on the branch history.
Terminal-style teaching diagram: git status → git add → git commit → git log --oneline (lab-style output, not a live account).
How Git answers that same fight
- Verify Git:
git --version(install from the official Git site if missing). - Set identity once:
git config --global user.nameanduser.email. mkdir myapp && cd myappthengit init— hidden.gitis the history database.- Write
README.md→git add README.md→git commit -m "Add README". - Empty GitHub repo →
git remote add origin <URL>→git push -u origin main.
Now developers and the server-side person share one story.
Commands on the laptop
git --version
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
mkdir myapp && cd myapp
git init
git branch -M main
echo "# myapp" > README.md
git status
git add README.md
git commit -m "Add README"
git log --oneline
git remote add origin <REPO_URL>
git push -u origin main
Working tree = files on disk. Staging = what the next commit includes. Repository = saved commits. Read git status twice; commit once.
Ravindra Bagale's Tip
Students type git commit without git add and wonder why the change vanished — same chaos as emailing an empty zip to Infosys client ops. Before every commit: git status. Lakshat theva.
What you should see
git log --onelineshows hash + message.- After push, GitHub lists your files.
- Clean tree:
git statussays nothing to commit, working tree clean.
Common errors — story pain then fix
| Pain from the stories | Likely cause | Fix |
|---|---|---|
Please tell me who you are |
Name/email not set | Set config before commit |
nothing added to commit |
Forgot git add |
Stage, then commit |
rejected on push |
Remote has commits you lack | git pull --rebase then push (when appropriate) |
| Wrong files in snapshot | Staged too much | Precise git add paths |
| Detached HEAD (later) | Checked out a hash | git checkout main |
Everyday commands after the first save
git status
git diff
git diff --staged
git log --oneline -5
git restore FILE
git rm FILE
Learn it properly
Samajla ka? Why Git = developer vs operations mystery-build fight; operations needs a known commit; Instagram / Netflix / Infosys “suppose” shows the mess; add → commit → push shares history. Five tiny commits tonight.
Frequently asked questions
What is Git?
Git is a version control system that stores snapshots (commits) of your project so you can track and undo changes.
What is a commit?
A commit is a saved snapshot with a message, author and unique hash.
What does git add do?
It stages chosen changes so the next commit includes only what you picked.
Do I need GitHub to use Git?
No. Git works locally. GitHub (or GitLab) is for remote hosting and teamwork.
What is the difference between Git and GitHub?
Git is the tool on your computer. GitHub is a website that hosts Git repositories.
Which branch name should beginners use?
Many new repos use main. Follow whatever your remote already uses.
Practice Tasks
Suppose we are on the DevOps team at IRCTC, the railway ticketing company, working from New Delhi. Suresh Yadav leads the team, and we look after the tatkal booking API. Costs are counted in INR. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. IRCTC is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.
0 / 12
Easy Set your Git email
Why: GitHub links commits to your account using this email.
What to do: Set the global Git email to suresh@irctc.example.com.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Set your Git user name
Why: Every commit records who made it. A wrong name makes history confusing.
What to do: Set the Git user name to "Suresh Yadav" for all repositories on this laptop.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy List all files with details
Why: Hidden files (like .env) and file sizes or owners only show with the right options.
What to do: Show a long listing of every file, including hidden ones, in /var/www/irctc.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Click Check answer.
Easy Stage every change
Why: Before the first commit you usually want every new file included.
What to do: Stage every new and changed file in the current folder and below.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Stage one file
Why: Only staged changes go into the next commit.
What to do: Stage only the file Dockerfile for the next commit.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Clone a repository
Why: Cloning gives you the full project and its history on your machine.
What to do: Download the repository https://github.com/irctc/irctc-tatkal-booking.git to this machine.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Commit with a message
Why: A clear message tells the team why the change was made.
What to do: Commit the staged changes with the message "Add health check to tatkal-booking".
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Start a new Git repository
Why: Git can only track changes inside a folder that is a repository.
What to do: We are inside the new folder for the IRCTC tatkal booking API. Turn this folder into a Git repository.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Easy Create nested folders in one go
Why: Projects need a clean folder tree. Making all levels in one command saves time and avoids errors.
What to do: Create the folder /srv/irctc/reports/2026 for IRCTC. The parent folders do not exist yet, so create them too.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Click Check answer.
Easy Show where you are
Why: Before you copy or delete anything, you must know which folder you are in.
What to do: Suresh Yadav logged in to the IRCTC server and is not sure which folder the terminal is in. Print the current folder path.
- Find the Linux command that does this job.
- Add the options (like -r or -h) the task needs.
- Add the file names, folders or users in the right order.
- Click Check answer.
Medium Stage tracked files and commit in one go
Why: For small fixes to tracked files, one command saves time.
What to do: Stage all already-tracked changed files and commit them with the message "Fix port 3000" in one command.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium See staged changes
Why: Reviewing exactly what will be committed avoids surprises in review.
What to do: Show the line-by-line changes that are staged (not the unstaged ones).
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.