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. लक्षात ठेवा: git add → git commit → git push.

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

Git का हवा आहे?

  1. Developers बदल संपवतात आणि “done” म्हणतात.
  2. Operations ला server side वर खात्रीची file हवी — तीन वेगवेगळ्या zip नाहीत.
  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” guess ने 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” परत आणू शकत नाही — खात्रीच नसते.

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 त्याच fight ला कसे उत्तर देते

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

समजलं का? 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.

सराव Tasks

या scenario बद्दल

समजा आपण IRCTC (रेल्वे तिकीट कंपनी) च्या DevOps team मध्ये नवी दिल्ली मधून काम करतो. Suresh Yadav team lead आहेत आणि आपण tatkal booking API सांभाळतो. खर्च INR मध्ये मोजला जातो. खालच्या tasks मध्ये या lesson मध्ये शिकलेलं वापरून आपण या project वर खरी DevOps कामं करतो. IRCTC ही खरी कंपनी आहे, पण हा project, लोक, servers, IP addresses व numbers सरावासाठी काल्पनिक आहेत.

0 / 12

सोपं Git email set करा

का: या email वरून GitHub commits तुमच्या account ला जोडतो.

काय करायचं: Global Git email suresh@irctc.example.com ठेवा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं Git user name set करा

का: प्रत्येक commit मध्ये कोणी केला ते नोंदवलं जातं. चुकीचं नाव असेल तर history गोंधळते.

काय करायचं: या laptop वरच्या सगळ्या repositories साठी Git user name "Suresh Yadav" ठेवा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं सर्व files details सह दाखवा

का: Hidden files (उदा. .env), sizes व owners योग्य options नेच दिसतात.

काय करायचं: /var/www/irctc मधल्या hidden files सह सगळ्या files ची long listing दाखवा.

कसं करायचं:
  1. हे काम करणारा Linux command शोधा.
  2. Task ला लागणारे options (उदा. -r, -h) जोडा.
  3. File नावं, folders किंवा users योग्य क्रमाने लिहा.
  4. Check answer दाबा.

सोपं सगळे बदल stage करा

का: पहिल्या commit आधी सहसा सगळ्या नवीन files हव्या असतात.

काय करायचं: सध्याच्या folder मधल्या व खालच्या सगळ्या नवीन व बदललेल्या files stage करा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं एक file stage करा

का: फक्त staged बदल पुढच्या commit मध्ये जातात.

काय करायचं: पुढच्या commit साठी फक्त Dockerfile ही file stage करा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं Repository clone करा

का: Clone केल्याने पूर्ण project व history तुमच्या machine वर येते.

काय करायचं: https://github.com/irctc/irctc-tatkal-booking.git ही repository या machine वर घ्या.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं Message सह commit करा

का: स्पष्ट message मुळे team ला बदल का केला ते समजतं.

काय करायचं: Staged बदल "Add health check to tatkal-booking" या message सह commit करा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं नवीन Git repository सुरू करा

का: Folder repository असेल तरच Git बदल track करतो.

काय करायचं: आपण IRCTC च्या tatkal booking API च्या नवीन folder मध्ये आहोत. हा folder Git repository बनवा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

सोपं एकाच वेळी nested folders बनवा

का: Project साठी स्वच्छ folder tree हवं. एका command ने सगळे levels बनवल्यास वेळ वाचतो.

काय करायचं: IRCTC साठी /srv/irctc/reports/2026 folder बनवा. Parent folders अजून नाहीत, तेही बनवा.

कसं करायचं:
  1. हे काम करणारा Linux command शोधा.
  2. Task ला लागणारे options (उदा. -r, -h) जोडा.
  3. File नावं, folders किंवा users योग्य क्रमाने लिहा.
  4. Check answer दाबा.

सोपं तुम्ही कुठे आहात ते पाहा

का: काही copy किंवा delete करण्याआधी तुम्ही कोणत्या folder मध्ये आहात हे माहीत हवं.

काय करायचं: Suresh Yadav IRCTC च्या server वर login झाले आहेत, पण terminal कोणत्या folder मध्ये आहे ते माहीत नाही. सध्याच्या folder चा path दाखवा.

कसं करायचं:
  1. हे काम करणारा Linux command शोधा.
  2. Task ला लागणारे options (उदा. -r, -h) जोडा.
  3. File नावं, folders किंवा users योग्य क्रमाने लिहा.
  4. Check answer दाबा.

मध्यम Tracked files stage करून एकदम commit

का: Tracked files मधल्या छोट्या fixes साठी एक command वेळ वाचवतो.

काय करायचं: आधीपासून tracked असलेल्या सगळ्या बदललेल्या files stage करून "Fix port 3000" message सह एकाच command मध्ये commit करा.

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.

मध्यम Staged बदल पाहा

का: नेमकं काय commit होणार ते पाहिल्याने review मध्ये आश्चर्य होत नाही.

काय करायचं: Staged बदल line by line दाखवा (unstaged नाही).

कसं करायचं:
  1. Task वाचा आणि कोणतं tool लागेल ते ठरवा (git, docker, kubectl, terraform, ansible...).
  2. आधी tool चं नाव, मग sub-command (action शब्द) लिहा.
  3. Task ला लागणारे flags व त्यांची value जोडा.
  4. शेवटी नावं, files किंवा paths लिहा आणि Check answer दाबा.