Printing is unavailable

This course is licensed for personal online viewing only.

Public preview • CL-P000000-C30-L366-0E14E1FC

Home Dashboard
Chapter 3 · Git Fundamentals

How Git Works

5,033
words
28
min read
4
tools

1. Learning Outcomes#

या chapter नंतर तुम्हाला:

  • Git मध्ये तुमच्या project मधील changes कशा प्रवास करतात ते समजेल
  • Working Directory म्हणजे काय ते समजेल
  • Staging Area ची गरज का आहे ते समजेल
  • Local Repository मध्ये commit केल्यानंतर काय होते ते समजेल
  • Remote Repository आणि local repository मधील फरक समजेल
  • edit → stage → commit → push हा basic Git workflow समजेल
  • modified, staged आणि committed या states मधील फरक समजेल
  • एखादा change लगेच repository मध्ये save होत नाही हे स्पष्ट होईल
  • real project मध्ये staging area कशी useful ठरते ते समजेल
  • basic Git workflow interview मध्ये explain करता येईल

2. Git मध्ये change नेमका कुठे जातो?#

समजा तुम्ही एका software project वर काम करत आहात.

Project मध्ये तीन files आहेत:

TEXT
login.html
login.css
login.js

तुम्ही login.js मध्ये काही code बदलला.

आता एक महत्त्वाचा प्रश्न आहे:

हा बदल Git history मध्ये लगेच save झाला का?

नाही.

File edit करणे आणि Git मध्ये त्या change ची permanent history तयार करणे या दोन वेगळ्या गोष्टी आहेत.

Git मध्ये change साधारणपणे अशा प्रवासातून जातो:

TEXT
Working Directory
      ↓
Staging Area
      ↓
Local Repository
      ↓
Remote Repository

हीच Git workflow समजण्याची मुख्य कल्पना आहे.

या चार जागांची भूमिका समजली की Git मधील add, commit, push यांसारख्या commands समजणे खूप सोपे होते.

3. Definition#

English Definition

Git uses a workflow in which changes can move from the working directory to the staging area, then into the local repository as commits, and optionally to a remote repository.

मराठी अर्थ

Git मध्ये आपण केलेला प्रत्येक change थेट final history मध्ये जात नाही. आधी आपण files वर काम करतो, नंतर कोणते changes पुढच्या commit मध्ये घ्यायचे ते निवडतो, मग त्यांचा commit तयार करतो आणि गरज असल्यास तो remote repository वर पाठवतो.

सोप्या भाषेत:

काम करा → change निवडा → history मध्ये save करा → team सोबत share करा

ही Git workflow ची basic mental model आहे.

4. Git Workflow चे चार मुख्य भाग#

Git समजताना खालील चार भाग वेगळे समजणे खूप महत्त्वाचे आहे:

Part मुख्य काम
Working Directory आपण files edit करतो
Staging Area पुढच्या commit मध्ये कोणते changes घ्यायचे ते निवडतो
Local Repository commits आणि project history आपल्या computer वर store होते
Remote Repository repository ची remote copy team/server वर उपलब्ध असते

आता प्रत्येक भाग step-by-step समजून घेऊ.

5. Working Directory#

Working Directory म्हणजे काय?#

Working Directory म्हणजे तुमच्या computer वर असलेला project चा तो भाग जिथे तुम्ही प्रत्यक्ष files पाहता आणि edit करता.

उदाहरण:

TEXT
my-project/
├── index.html
├── style.css
└── app.js

तुम्ही VS Code मध्ये app.js open करून code बदलत असाल, तर तुम्ही Working Directory मध्ये काम करत आहात.

Working Directory ला काही वेळा working tree असेही म्हटले जाते.

या chapter साठी दोन्हींचा basic अर्थ एकच समजा:

तुमच्या project च्या सध्या उपलब्ध आणि edit करता येणाऱ्या files.

Working Directory मध्ये काय होते?#

इथे तुम्ही:

  • नवीन file तयार करू शकता
  • existing file edit करू शकता
  • file delete करू शकता
  • code लिहू शकता
  • configuration बदलू शकता

परंतु:

महत्त्वाचे

Working Directory मध्ये file बदलली म्हणजे त्या change चा Git commit तयार झाला असा अर्थ नाही.

हा beginner साठी खूप महत्त्वाचा point आहे.

समजा:

TEXT
app.js

या file मध्ये आधी:

JAVASCRIPT
console.log("Hello");

होते.

तुम्ही ते बदलून:

JAVASCRIPT
console.log("Hello Git");

केले.

File save झाली.

पण अजून Git history मध्ये नवीन commit तयार झालेला नाही.

तुम्ही फक्त Working Directory बदलली आहे.

6. Modified State#

Git आधीपासून track करत असलेल्या file मध्ये change केल्यावर ती file साधारणपणे modified state मध्ये जाते.

उदाहरण:

TEXT
app.js

तुम्ही file edit केली.

Mental model:

TEXT
Original committed version
        ↓
You edit the file
        ↓
Modified file in Working Directory

modified म्हणजे:

file मध्ये बदल झाला आहे, पण हा बदल अजून पुढच्या commit साठी stage केलेला नाही.

Remember

File save करणे आणि Git commit करणे वेगळे आहे.

VS Code मध्ये Ctrl + S केल्याने file disk वर save होते.

पण त्यामुळे Git commit तयार होत नाही.

7. Staging Area#

Working Directory समजल्यानंतर Git मधील सर्वात महत्त्वाची beginner concept म्हणजे Staging Area.

एक problem पाहूया#

समजा तुम्ही project मध्ये तीन changes केले:

TEXT
login.html   → login form बदलला
style.css    → button color बदलला
app.js       → temporary debugging code add केला

आता तुम्हाला commit मध्ये फक्त:

TEXT
login.html
style.css

हे changes घ्यायचे आहेत.

app.js मधील debugging change अजून commit करायचा नाही.

जर Git कडे selection करण्यासाठी मधली जागाच नसती, तर प्रत्येक बदल commit मध्ये घ्यावा लागला असता.

इथे Staging Area उपयोगी पडते.

Staging Area म्हणजे काय?#

Staging Area म्हणजे पुढच्या commit मध्ये कोणते changes समाविष्ट करायचे आहेत ते निवडून ठेवण्याची intermediate जागा.

सोप्या भाषेत:

Working Directory = केलेले सर्व changes

Staging Area = पुढच्या commit साठी निवडलेले changes

उदाहरण:

TEXT
Working Directory Changes

login.html   ✓ changed
style.css    ✓ changed
app.js       ✓ changed

पण तुम्ही stage केले:

TEXT
Staging Area

login.html   ✓
style.css    ✓

app.js अजून Working Directory मध्ये modified राहू शकते.

त्यामुळे पुढचा commit फक्त login-related changes चा बनवता येतो.

Staging Area का आवश्यक आहे?#

याचा मोठा फायदा म्हणजे control.

Developer म्हणून तुम्ही ठरवू शकता:

"मी केलेल्या सर्व changes पैकी कोणते changes या commit मध्ये घ्यायचे?"

हे real project मध्ये खूप उपयोगी आहे.

समजा तुम्ही एकाच वेळी:

  • login bug fix केला
  • dashboard वर experimental change केला
  • debugging logs add केले

आता login bug production साठी ready आहे.

Dashboard experiment अजून incomplete आहे.

Staging Area मुळे फक्त login bug शी संबंधित changes commit करता येतात.

Key Idea

Staging Area म्हणजे changes store करण्याची random extra copy नसून पुढच्या commit चे content निवडण्याची जागा आहे.

8. git add ची basic भूमिका#

Concept समजण्यासाठी command चा basic relation पाहू.

Working Directory मधील change Staging Area मध्ये निवडण्यासाठी Git मध्ये git add वापरला जातो.

उदाहरण:

BASH
git add login.html

याचा beginner-level अर्थ:

login.html मधील सध्याचा change पुढच्या commit मध्ये घेण्यासाठी stage करा.

Mental model:

TEXT
login.html
Working Directory
      ↓
   git add
      ↓
Staging Area

इथे अजून commit तयार झालेला नाही.

तुम्ही फक्त change निवडला आहे.

Common Mistake

git add म्हणजे file GitHub वर upload करणे नाही.

git add मुख्यतः change stage करते.

Remote repository पर्यंत change अजून गेलेला नसतो.

9. Working Directory आणि Staging Area मधील फरक#

हे दोन concepts beginners अनेकदा confuse करतात.

Working Directory Staging Area
तुम्ही प्रत्यक्ष files edit करता पुढच्या commit साठी changes निवडले जातात
सर्व current edits इथे असू शकतात निवडलेले changes इथे असतात
change modified असू शकतो change staged असतो
commit तयार झालेला नसतो अजूनही commit तयार झालेला नसतो

सोप्या उदाहरणाने:

समजा table वर अनेक documents पडले आहेत.

ते म्हणजे Working Directory.

त्यापैकी उद्या manager ला द्यायचे documents तुम्ही वेगळ्या folder मध्ये ठेवले.

तो folder म्हणजे Staging Area.

अजून documents officially submit केलेले नाहीत.

फक्त कोणते submit करायचे ते ठरवले आहे.

Git मध्येही staging साधारणपणे अशीच भूमिका बजावते.

10. Staged State#

जेव्हा एखादा change Staging Area मध्ये जातो तेव्हा आपण तो change staged आहे असे म्हणतो.

Flow:

TEXT
File edited
   ↓
Modified
   ↓
Selected for next commit
   ↓
Staged

staged म्हणजे:

हा change पुढच्या commit मध्ये समाविष्ट करण्यासाठी तयार आहे.

11. Local Repository#

आता पुढचा प्रश्न:

Staging Area मध्ये changes निवडले.

पुढे काय?

आता त्या changes चा commit तयार करता येतो.

Commit तयार झाल्यानंतर history Local Repository मध्ये store होते.

Local Repository म्हणजे काय?#

Local Repository म्हणजे तुमच्या स्वतःच्या computer वर असलेली Git repository आणि तिची version history.

यामध्ये Git project च्या commits विषयी माहिती ठेवते.

सोप्या भाषेत:

Working Directory मध्ये तुम्ही काम करता.

Staging Area मध्ये पुढच्या commit साठी changes निवडता.

Local Repository मध्ये commits च्या रूपात history ठेवली जाते.

Commit म्हणजे काय?#

commit म्हणजे project च्या निवडलेल्या staged changes चा history point.

Beginner mental model म्हणून commit ला project चा meaningful saved checkpoint समजू शकता.

उदाहरण:

TEXT
Commit 1
Initial project

Commit 2
Added login page

Commit 3
Fixed login validation

या commits मुळे project कसा बदलत गेला याची history तयार होते.

महत्त्वाचे

Commit हा normal Save सारखा नाही. File save करणे editor/filesystem level वर होते. Commit Git history मध्ये meaningful version तयार करतो.

12. git commit ची basic भूमिका#

Staging Area मधील changes Local Repository मध्ये commit करण्यासाठी git commit वापरला जातो.

उदाहरण:

BASH
git commit -m "Add login form"

Conceptually:

TEXT
Staging Area
     ↓
 git commit
     ↓
Local Repository

आता staged changes चा commit तयार झाला.

त्या commit ला message दिला:

TEXT
Add login form

Commit message चा purpose म्हणजे त्या commit मध्ये काय बदलले ते short form मध्ये सांगणे.

13. Commit झाल्यावर काय बदलते?#

समजा:

TEXT
login.html
style.css

हे दोन्ही stage केले होते.

नंतर commit केला.

आता त्या selected changes ची history Local Repository मध्ये save झाली.

Flow:

TEXT
Working Directory
      ↓ git add
Staging Area
      ↓ git commit
Local Repository

हा Git चा सर्वात fundamental flow आहे.

14. Git Snapshot ची basic कल्पना#

Git commits बद्दल बोलताना snapshot हा शब्द तुम्हाला वारंवार ऐकायला मिळेल.

सोप्या भाषेत:

Commit तयार होताना Git project च्या त्या version ची माहिती history मध्ये ठेवते.

म्हणून आपण beginner level वर असे म्हणू शकतो:

Commit हा project च्या त्या वेळच्या selected state चा checkpoint/snapshot आहे.

यामुळे history अशी दिसू शकते:

TEXT
Version A
   ↓
Version B
   ↓
Version C

उदाहरण:

TEXT
Initial Project
      ↓
Login Added
      ↓
Validation Added
      ↓
Bug Fixed

यामुळे नंतर developer ला project मध्ये कोणते changes कधी झाले हे समजणे सोपे होते.

15. Local Repository तुमच्या computer वर असते#

हा point स्पष्ट असणे आवश्यक आहे.

तुम्ही commit केला म्हणजे तो change automatically GitHub किंवा इतर remote server वर गेला असे नाही.

Commit आधी तुमच्या Local Repository मध्ये तयार होतो.

उदाहरण:

TEXT
Your Computer

Working Directory
      ↓
Staging Area
      ↓
Local Repository

या stage पर्यंत internet ची गरज असणे आवश्यक नाही.

तुमची local Git history तुमच्या machine वर असू शकते.

Remember

commit आणि push एकच operation नाहीत.

commit:

TEXT
Staging Area → Local Repository

push:

TEXT
Local Repository → Remote Repository

हा फरक interview आणि practical काम दोन्हीसाठी महत्त्वाचा आहे.

16. Remote Repository#

आता Local Repository समजली.

पण team मध्ये पाच developers असतील तर?

प्रत्येक developer च्या computer वर त्याची Local Repository असू शकते.

मग team changes share कशी करणार?

इथे Remote Repository उपयोगी पडते.

Remote Repository म्हणजे काय?#

Remote Repository म्हणजे तुमच्या local machine च्या बाहेर उपलब्ध असलेली repository, जी team members changes share आणि synchronize करण्यासाठी वापरू शकतात.

ती एखाद्या remote hosting service किंवा server वर असू शकते.

उदाहरणार्थ:

  • GitHub
  • GitLab
  • Bitbucket
  • company Git server

या services Git repositories host करू शकतात.

Git आणि GitHub एकच गोष्ट नाहीत.

Git ही version control system आहे.

GitHub ही Git repositories host करण्यासाठी वापरली जाणारी एक popular service आहे.

Common Mistake

Git शिकणे म्हणजे फक्त GitHub शिकणे नाही. Git local machine वरसुद्धा काम करते.

17. Local Repository आणि Remote Repository मधील फरक#

Local Repository Remote Repository
तुमच्या computer वर असते remote server/service वर असते
local commits store करते shared commits store करू शकते
तुमच्या local development चा भाग collaboration आणि sharing साठी उपयोगी
commit इथे तयार होतो commit push करून इथे पाठवता येतो
internet शिवाय local work शक्य remote communication साठी network लागतो

या फरकाचा mental model:

TEXT
Developer's Computer
┌─────────────────────────┐
│ Working Directory       │
│        ↓                │
│ Staging Area            │
│        ↓                │
│ Local Repository        │
└───────────┬─────────────┘
            │
            │ push
            ▼
┌─────────────────────────┐
│ Remote Repository       │
└─────────────────────────┘

18. git push ची basic भूमिका#

Local Repository मध्ये तयार झालेले commits Remote Repository कडे पाठवण्यासाठी git push वापरला जातो.

Conceptual flow:

TEXT
Local Repository
      ↓
   git push
      ↓
Remote Repository

समजा तुम्ही local machine वर commit केला:

TEXT
Add login validation

हा commit अजून तुमच्या local repository मध्ये आहे.

Remote repository वर पाठवण्यासाठी push करता.

यानंतर team मधील इतर developers ना तो commit मिळवता येऊ शकतो.

Key Idea

git push Working Directory मधील unsaved किंवा uncommitted changes थेट remote वर पाठवत नाही. साधारण workflow मध्ये आधी commit तयार होतो आणि मग commits remote कडे push केले जातात.

19. Remote वरून changes आपल्या machine वर कसे येतात?#

Team member ने remote repository वर नवीन commits push केले असतील.

तुमच्या local project ला ते changes मिळवावे लागतील.

Basic Git workflow मध्ये तुम्हाला pull हा शब्दही दिसेल.

Beginner level वर:

git pull म्हणजे remote repository मधील नवीन work आपल्या local side वर आणण्यासाठी वापरला जाणारा command.

Conceptually:

TEXT
Remote Repository
      ↓
    pull
      ↓
Local working environment

यामागे अधिक technical operations असू शकतात, पण basic workflow समजण्यासाठी एवढे लक्षात ठेवा:

push → आपले commits remote कडे पाठवणे

pull → remote वरचे नवीन work आपल्या local side वर आणणे

20. Complete Basic Git Workflow#

आता सगळे concepts एकत्र जोडू.

समजा तुम्हाला login form तयार करायचा आहे.

Step 1: File edit करा#

तुम्ही:

TEXT
login.html

edit केली.

हा change Working Directory मध्ये आहे.

TEXT
Working Directory

login.html → modified

Step 2: Change stage करा#

हा change पुढच्या commit मध्ये घ्यायचा आहे.

Conceptually:

BASH
git add login.html

आता:

TEXT
Staging Area

login.html → staged

Step 3: Commit तयार करा#

आता staged change history मध्ये save करायचा.

उदाहरण:

BASH
git commit -m "Add login form"

आता commit Local Repository मध्ये तयार झाला.

TEXT
Local Repository

Commit: Add login form

Step 4: Commit remote वर पाठवा#

Team सोबत share करण्यासाठी:

BASH
git push

Conceptually commit Remote Repository कडे पाठवला जातो.

पूर्ण flow:

Visual Diagram80%

Rendering diagram…

हा diagram डावीकडून उजवीकडे वाचा.

  1. सुरुवातीला developer file edit करतो.
  2. तो change Working Directory मध्ये असतो.
  3. git add मुळे निवडलेला change Staging Area मध्ये जातो.
  4. git commit मुळे staged changes चा commit Local Repository मध्ये तयार होतो.
  5. git push मुळे local commits Remote Repository कडे पाठवता येतात.

हा flow Git च्या basic day-to-day usage चा foundation आहे.

21. एका File चा State कसा बदलतो?#

एकाच file चे example पाहू.

सुरुवातीला:

TEXT
app.js

Git history च्या current version शी match करते.

नंतर developer ती edit करतो.

TEXT
app.js → modified

Stage केल्यावर:

TEXT
app.js → staged

Commit केल्यानंतर:

TEXT
app.js changes → committed

Visual flow:

Visual Diagram80%

Rendering diagram…

इथे मुख्य गोष्ट notice करा:

edit, stage आणि commit या तीन स्वतंत्र steps आहेत.

File edit झाली म्हणजे ती staged झालीच असे नाही.

File staged झाली म्हणजे commit तयार झाला असेही नाही.

प्रत्येक step ची वेगळी भूमिका आहे.

22. Staging Area चा practical फायदा#

समजा तुम्ही चार files बदलल्या:

TEXT
login.html
login.js
dashboard.html
debug.js

तुमचे काम असे आहे:

TEXT
login.html      → login feature
login.js        → login feature
dashboard.html  → unfinished experiment
debug.js        → temporary debugging

तुम्हाला login feature चाच commit तयार करायचा आहे.

तुम्ही फक्त:

TEXT
login.html
login.js

stage करू शकता.

Conceptually:

TEXT
Working Directory
├── login.html       → modified
├── login.js         → modified
├── dashboard.html   → modified
└── debug.js         → modified

Staging Area:

TEXT
login.html
login.js

Commit:

TEXT
Add login feature

यामुळे commit focused आणि meaningful राहतो.

जर प्रत्येक unrelated change एकाच commit मध्ये टाकला तर नंतर history समजणे कठीण होऊ शकते.

23. Good Commit Thinking#

Beginner म्हणून सुरुवातीपासून एक habit तयार करा:

एका commit मध्ये logically related changes ठेवण्याचा प्रयत्न करा.

उदाहरणार्थ:

चांगले commit purpose:

TEXT
Fix login validation

यामध्ये login validation शी संबंधित changes असावेत.

Unrelated changes एकत्र टाकण्यापेक्षा focused commits project history समजण्यास मदत करतात.

24. git status कुठे useful आहे?#

Git वापरताना एक common प्रश्न असतो:

"माझ्या files ची सध्या स्थिती काय आहे?"

उदाहरणार्थ:

  • कोणती file modified आहे?
  • कोणती staged आहे?
  • काही changes commit साठी तयार आहेत का?

यासाठी git status हा command उपयोगी असतो.

BASH
git status

या chapter मध्ये command output च्या details मध्ये जाण्याची गरज नाही.

आत्ता एवढे लक्षात ठेवा:

git status तुम्हाला repository च्या current working state बद्दल माहिती देतो.

25. एक महत्त्वाचा फरक: Save vs Stage vs Commit vs Push#

हे चार actions वेगळे आहेत.

Action काय होते?
Save editor मधील file change disk वर save होतो
Stage change पुढच्या commit साठी select होतो
Commit selected changes ची Git history तयार होते
Push local commits remote repository कडे पाठवले जातात

ही sequence लक्षात ठेवा:

TEXT
Save
  ↓
Stage
  ↓
Commit
  ↓
Push

परंतु याचा अर्थ प्रत्येक छोट्या save नंतर लगेच हे सर्व करावेच लागते असा नाही.

Developer अनेक edits करू शकतो आणि योग्य वेळी logically related changes stage आणि commit करू शकतो.

26. Common Beginner Confusions#

Confusion 1: File save केली म्हणजे commit झाला#

नाही.

File save करणे editor/filesystem operation आहे.

Commit हा Git operation आहे.

Confusion 2: git add म्हणजे GitHub वर file upload झाली#

नाही.

git add change Staging Area मध्ये select करते.

Remote repository पर्यंत change गेलेला नसतो.

Confusion 3: Commit केला म्हणजे team ला change मिळाला#

नेहमीच नाही.

Commit आधी Local Repository मध्ये तयार होतो.

Remote repository वर share करण्यासाठी push आवश्यक असू शकतो.

Confusion 4: Working Directory आणि Local Repository एकच आहेत#

नाही.

Working Directory मध्ये तुम्ही visible project files वर काम करता.

Local Repository Git history आणि commits maintain करते.

Confusion 5: Remote Repository म्हणजेच Git#

नाही.

Git स्वतः local version control करू शकते.

Remote repository collaboration आणि sharing साठी उपयोगी असते.

27. Real Team Example#

समजा Amit आणि Neha एकाच project वर काम करत आहेत.

दोघांकडे project ची local copy आहे.

Amit login feature वर काम करतो.

त्याचा flow:

TEXT
Edit login files
      ↓
Stage login changes
      ↓
Commit locally
      ↓
Push commit to remote

Remote repository वर आता Amit चा commit उपलब्ध आहे.

Neha ला तो change घ्यायचा आहे.

ती remote मधील latest work आपल्या local side वर आणू शकते.

Mental model:

Visual Diagram80%

Rendering diagram…

या diagram मध्ये:

  1. Amit आधी त्याचा commit local repository मध्ये तयार करतो.
  2. तो commit remote repository वर push करतो.
  3. Remote repository team साठी shared point म्हणून काम करते.
  4. Neha remote वरून नवीन changes आपल्या local environment मध्ये घेऊ शकते.

यामुळे अनेक developers एकाच codebase वर coordinated पद्धतीने काम करू शकतात.

28. Basic Workflow लक्षात ठेवण्याची सोपी पद्धत#

चार प्रश्न विचारा:

1. मी कुठे काम करतो?#

Working Directory

2. पुढच्या commit मध्ये काय घ्यायचे ते कुठे निवडतो?#

Staging Area

3. Commit कुठे तयार होतो?#

Local Repository

4. Team सोबत commits कुठे share करू शकतो?#

Remote Repository

आणि चार common actions:

TEXT
Edit → Add → Commit → Push

त्यांचा अर्थ:

TEXT
Edit
↓
Working Directory बदलते

Add
↓
Change stage होतो

Commit
↓
Local history तयार होते

Push
↓
Local commits remote वर जातात

29. Hands-On Practice#

Practice 1#

Requirement

समजा तुम्ही खालील दोन files edit केल्या:

TEXT
profile.html
profile.css

पण पुढच्या commit मध्ये फक्त profile.html चा change घ्यायचा आहे.

Your Task

खालील प्रत्येक step मध्ये profile.html कुठे असेल ते ओळखा:

  1. File edit केल्यानंतर
  2. पुढच्या commit साठी select केल्यानंतर
  3. Commit तयार केल्यानंतर
  4. Commit team repository वर पाठवल्यानंतर
HintShow Hint

चार मुख्य areas लक्षात ठेवा:

TEXT
Working Directory
Staging Area
Local Repository
Remote Repository
SolutionShow Solution
  1. Edit केल्यानंतर → Working Directory
  2. Select/stage केल्यानंतर → Staging Area
  3. Commit केल्यानंतर → Local Repository
  4. Push केल्यानंतर → Remote Repository

Explanation

File edit झाल्यावर ती Working Directory मध्ये modified असते.

Stage केल्यावर change पुढच्या commit साठी निवडला जातो.

Commit केल्यावर त्या staged change ची history Local Repository मध्ये तयार होते.

Push केल्यावर local commit Remote Repository वर share करता येतो.

Practice 2#

Requirement

Developer ने तीन changes केले:

TEXT
login.js       → completed bug fix
dashboard.js   → incomplete experiment
debug.js       → temporary logging

फक्त login bug fix commit करायचा आहे.

Your Task

Staging Area मध्ये कोणता change असायला हवा?

HintShow Hint

Commit चा purpose आहे:

TEXT
Fix login bug
SolutionShow Solution
TEXT
login.js

शी संबंधित completed bug-fix change stage करणे योग्य आहे.

Explanation

Staging Area मुळे developer ला सर्व modified files commit करण्याची गरज पडत नाही.

तो logically related आणि ready changes निवडू शकतो.

या example मध्ये incomplete experiment आणि temporary debugging change login bug fix commit मध्ये घेणे आवश्यक नाही.

30. Interview Preparation#

What is the staging area in Git?Show Answer

The staging area is an intermediate area where developers select the changes that should be included in the next commit.

Key Points:

  • It exists between the working directory and the local repository.
  • It allows selective commits.
  • Changes are typically staged before creating a commit.

Why interviewer asks this:

The interviewer wants to verify that you understand Git's basic workflow instead of treating git add and git commit as commands to memorize.

What is the difference between the working directory and the staging area?Show Answer

The working directory contains the files currently being edited, while the staging area contains the selected changes that are prepared for the next commit.

Key Points:

  • Working directory represents current editable files.
  • Staging area represents selected changes.
  • Not every modified change must be staged immediately.

Why interviewer asks this:

This checks whether you understand the purpose of staging and selective commits.

What is the difference between a local repository and a remote repository?Show Answer

A local repository exists on the developer's machine and stores local Git history and commits. A remote repository exists on another server or hosting service and is commonly used to share and synchronize commits between developers.

Key Points:

  • Commits can be created locally.
  • A remote repository supports collaboration.
  • A commit does not automatically mean the change has been pushed remotely.

Why interviewer asks this:

The interviewer wants to know whether you understand the difference between local version control and remote collaboration.

Explain the basic Git workflow.Show Answer

A developer edits files in the working directory, stages selected changes in the staging area, creates a commit in the local repository, and can then push the commit to a remote repository.

Key Points:

  • Edit
  • Stage
  • Commit
  • Push
  • Each step has a separate purpose

Why interviewer asks this:

This is one of the fundamental Git questions and verifies whether you understand how changes move through Git.

31. या Chapter मधून काय लक्षात ठेवायचे?#

  • तुम्ही files वर प्रत्यक्ष काम करता ती जागा म्हणजे Working Directory
  • edit केलेली file लगेच commit होत नाही
  • modified change पुढच्या commit साठी निवडला की तो staged होतो
  • Staging Area पुढच्या commit चे changes select करण्यासाठी वापरली जाते
  • git add चा basic purpose म्हणजे changes stage करणे
  • git commit staged changes ची local history तयार करतो
  • commits Local Repository मध्ये तयार होतात
  • Remote Repository collaboration आणि sharing साठी उपयोगी असते
  • git push local commits remote repository कडे पाठवते
  • commit आणि push वेगळ्या गोष्टी आहेत
  • basic mental model आहे:
TEXT
Working Directory
      ↓
Staging Area
      ↓
Local Repository
      ↓
Remote Repository

आणि basic action flow:

TEXT
Edit → Stage → Commit → Push
Remember

Git समजण्यासाठी commands पाठ करण्यापेक्षा प्रत्येक command change ला एका state मधून दुसऱ्या state मध्ये कसा घेऊन जातो हे समजणे जास्त महत्त्वाचे आहे.

Interactive learning

Practice lab

Apply this chapter with guided activities, immediate feedback, explanations, and retry.

Practice loads when this section enters view.