|3. Staging आणि Commits
Chapter 3Git & GitHub~1 min read

Staging आणि Commits

Code Save करायला शिका

Git मध्ये code save करणे म्हणजे commit करणे. पण commit करण्याआधी कोणत्या files save करायच्या ते staging area मध्ये add कराव्या लागतात. हे दोन-step process आहे.

Marathi Analogy

Staging area म्हणजे parcel पाठवण्याआधीचा box. आधी box मध्ये सामान भरा (git add), मग label लावून post करा (git commit). ज्या सामानाचा box भरला नाही ते post होणार नाही!

Basic Git workflow

bash
# 1. Status बघा — कोणत्या files बदलल्या
git status

# 2. Files staging area मध्ये add करा
git add index.html          # specific file
git add src/               # folder
git add .                  # सगळ्या changed files

# 3. Commit करा — snapshot घ्या
git commit -m "Add homepage layout"

# 4. History बघा
git log
git log --oneline          # short version

git status चे colors समजून घ्या

  • Red = Modified/new files, staging area मध्ये नाहीत
  • Green = Staged files — commit साठी ready
  • Nothing shown = Working directory clean (no changes)

Useful shortcuts

bash
# Stage + Commit एकत्र (नवीन files साठी नाही)
git commit -am "Fix button color"

# शेवटचा commit बघा
git show

# Staged changes बघा
git diff --staged

# Unstaged changes बघा
git diff
📌

Commit message नेहमी imperative present tense मध्ये लिहा: "Add feature" (✅), "Added feature" (❌). Team मध्ये consistent messages खूप important असतात.

Key Points — लक्षात ठेवा

  • git status — current state बघा
  • git add — files staging area मध्ये टाका
  • git commit -m "message" — snapshot घ्या
  • git log — commit history बघा
  • Working directory → Staging Area → Repository
0/10 chapters पूर्ण