Skip to content

Git Stage3: Local Repository

Git me 3 main cheezein hoti hain:

  1. Blob → file ka CONTENT
  2. Tree → folder / directory ka SNAPSHOT
  3. Commit → ek PHOTO + history note

Commit

Jab aap code ko Stagging area se Commit karenge to wo local repo ke default branch me chali jaayegi aur iska snamshot le liya jaayega. ham isko change bhi kar sakte hai ki kis branch me jaana hai.

  • snapshot le liya. Yani aapne un lamhat ko un palo ko kaid kar liya. Ab aap kabhi bhi ki us samay pe code kaisa tha to aap ja ke dekh sakte ho.
  • Snapshot incrimental backup hota hai - incremental backup matlab sirf nayi cheeje backup hongi, to yaha sirf nayi line of codes ya modified codes hi save hoti hai snapshot me
  • commit SHA-1 checksum use karta hai integrity(ईमानदारी) ke liye, matlabb code thoda bhi change hoga to ye change ho jaayega
  • SHA-1 -> Ye kisi bhi data ko fixed length (40 hex characters) ke unique fingerprint me badal deta hai

Commit

Code ko staging area se local repo me bhejne ko commit kahte hai

Commit ID ka matlab kya hota hai?

Jab tum git commit karte ho, Git ye data banata hai (raw form me):

commit <size>\0
tree <tree-sha>
parent <parent-commit-sha>   (first commit me nahi hota)
author Name <email> timestamp
committer Name <email> timestamp

Commit message

Is upar wale poore text ka SHA-1 nikala jaata hai, That SHA-1 = commit ID

Isliye commit bhi object hota hai

commit 86b8ab38c026e9a4a11052a8c8b39a58418f62bd (HEAD -> main)

Git isko store karta hai exactly blob jaise:

.git/objects/86/b8ab38c026e9a4a11052a8c8b39a58418f62bd

Iss file me kya hota hai?

[x@archlinux Git-Learn]$ git log
commit 86b8ab38c026e9a4a11052a8c8b39a58418f62bd (HEAD -> main)
Author: rishabh679 <me.rishabhh.com>
Date:   Mon Jan 26 23:46:52 2026 +0530

    two file commited

# command to see content inside commit blob

# git cat-file -p commit id

[x@archlinux Git-Learn]$ git cat-file -p 86b8ab38c026e9a4a11052a8c8b39a58418f62bd
tree 9577b4d6b2f9e7716c1a5a62a188d79ebcc9c361
author rishabh679 <me.rishabhh.com> 1769451412 +0530
committer rishabh679 <me.rishabhh.com> 1769451412 +0530

two file commited

TL;DR

Git commit karoge to staging area se code files local repo me aa jaayenge aur ek commit id banti hai. is commit id ka use karke ham us samay par jaa sakt e hai

Remote Repository (GitHub)

Abtak aapne apane code ko commit kar diya hai, yani apane local repository me laa chuke hai aab aapko ise server pe daalna hai taki sab log dekh sake.

git push

Remote repo pe code ko daalne ke liye aap $git push karoge

git pull

Ab koi teesra banda aapne jaha tak kaam kiya tha uske aage kaam karna chahata hai to wo remote repo se $git pull karega yani aapne jaha tak code ko push kiya tha waha tak ka code uske pc me download ho jaayega bikul waise hi jaise aapke pc me tha git push karne ke samay. aur ab ye banda apane pc me kaam chaku rakh sakta hai aur phir se ye wahi sari steps dusrayega.