Ravindra BagaleCourses & study guides Track your progress

Guides

DevOps शुरुआती के लिए Git Basics

Read this guide in: English · मराठी · हिंदी

Why Git चाहिए? क्योंकि developers और operations के बीच असली problem है जब history सिर्फ़ zip हो। Developers laptop पर code बदलते हैं। Operations — server side वाला employee — “आख़िरी जो build आया” उसे copy करता है। Friday night कौन‑सी file live है किसी को पता नहीं। Git दोनों पक्ष जोड़ता है: हर save एक commit (कौन, कब, क्यों), फिर git push से वही history GitHub पर।

दोस्तों, बीस Git commands से शुरू मत करो। पहले mystery-build fight समझो। फिर add, commit, push आसान लगेगा।

संक्षिप्त उत्तर

यह खड़ा नक्शा पकड़ो:

  1. Developer — laptop पर code edit करता है।
  2. Operations — server-side employee जिसे known version server पर रखना है।
  3. Problem — WhatsApp/email zips; author नहीं; “कौन‑सा build live?”
  4. Git — commits mystery zips बदलते हैं; push एक history team के साथ साझा करता है।
  5. Pocket verbs: git add → git commit → git push।

Language: English · मराठी · हिंदी

Git क्यों चाहिए?

  1. Developers बदलाव खत्म कर “done” कहते हैं।
  2. Operations को server side पर भरोसेमंद file चाहिए — तीन अलग zips नहीं।
  3. Production टूटे तो दोनों को चाहिए: किसने क्या बदला, कब?

इसलिए pipelines से पहले Git सीखो।

Operations का Git से क्या रिश्ता?

  1. Operations = server-side employee (या team)।
  2. उनका दिन: deploy, restart, logs, rollback।
  3. Git न हो तो zip guess। Git हो तो known commit deploy।

Problem क्या है? Suppose we are…

Suppose we are building Instagram (like updates)

Suppose team Instagram-style profile badges ship करती है। Developer A profile-final.zip email करता है; B profile-FINAL-v2.zip WhatsApp करता है; operations “latest” अटकल से production पर copy करता है; Friday page गलत।

Suppose we are working at Netflix and we are giving updates

Suppose Netflix हफ़्ते में कई छोटे home-screen fixes देता है। History सिर्फ़ chat के zip नाम हों तो operations आत्मविश्वास से “Tuesday का अच्छा build” rollback नहीं कर सकता।

Suppose you are working in Infosys on a client project

Suppose दो Infosys developers client operations को builds email करते हैं। Client पूछता है: कौन‑सा attachment approve है? Git + review न हो तो release day war room।

Git: working tree, staging, commit history Edit files in the working tree, git add to stage, git commit to save a snapshot. Commits form history on the branch. Working tree edit files README.md add Staging git add index commit Repository (.git) git commit · snapshots c1 c2 c3 main → History answers: which build is live? (no mystery zip) status → add → commit Then git push shares the same history with the team / operations

Git path: edit in the working tree, git add to stage, git commit to save a snapshot on the branch history.

Git status, add, commit, log Terminal-style teaching diagram of git status, git add, git commit and git log --oneline.

Terminal-style teaching diagram: git status → git add → git commit → git log --oneline (lab-style output, not a live account).

Git उसी लड़ाई का जवाब कैसे देता है

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 = disk की files। Staging = अगले commit में क्या। Repository = saved commits। git status दो बार पढ़ो; एक बार commit करो।

Ravindra Bagale's Tip

Students git add के बिना git commit टाइप करते हैं — Infosys client ops को खाली zip email जैसा। हर commit से पहले git status। याद रखो।

आपको क्या दिखना चाहिए

  1. git log --oneline — hash + message।
  2. Push के बाद GitHub पर files।
  3. Clean tree: nothing to commit, working tree clean।

Common errors

Stories का pain कारण Fix
Please tell me who you are Name/email नहीं Config सेट करें
nothing added to commit git add भूले Stage, फिर commit
rejected on push Remote पर commits आपके पास नहीं git pull --​rebase फिर push
गलत files snapshot में ज़्यादा stage Precise git add
Detached HEAD Hash checkout git checkout main

Samajla ka? Why Git = mystery-build fight; operations को known commit चाहिए; Instagram / Netflix / Infosys “suppose”; add → commit → push। आज रात पाँच छोटे commits।

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

About this scenario

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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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".

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. 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.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. 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.

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. 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).

How:
  1. Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
  2. Write the tool name, then the sub-command (the action word).
  3. Add the flags the task needs, each followed by its value.
  4. Add names, files or paths at the end, then click Check answer.