howitworks.io logohowitworks
← Saari reels
Dev toolsReel #24 · 3 Nov 2026

Git andar se kaise kaam karta hai: objects, hash, branch, reflog aur gc

Git User's Survey 2010 (8,546 jawab) mein sirf 6.6% developers ne khud ko Git expert bataya. Git files ka folder nahi, objects ka database hai: blob (sirf content), tree (naam aur folders), commit (top tree, parent, author, message). Har object ka naam uske content ka SHA-1 hash hai, isliye ek character badalne par naya object banta hai aur purani history chupchaap nahi badalti. Branch ek 41 byte ki file hai jismein ek commit ka hash hota hai. Branches, tags aur HEAD se pahunch mein aane wale (reachable) commits safe hain. reset --hard ke baad git reflog purane hashes dikhata hai. Default gc rules (git-config docs): gc.reflogExpire 90 din, gc.reflogExpireUnreachable 30 din, gc.pruneExpire 2 hafte.

Links

Aaj ye karo

  1. Apne project mein git reflog chalao: har commit, checkout aur reset ka record hash ke saath dikhega.
  2. Kisi bhi object ke andar dekho: git cat-file -p HEAD (commit), phir uske tree ka hash, phir kisi blob ka hash.
  3. Galti se reset --hard ho gaya? git reflog mein reset se theek pehle wali entry dekho aur git reset --hard HEAD@{1} chalao.
  4. Branch delete ho gayi? Git delete karte waqt hash batata hai (was abc1234); git branch rescue abc1234 se wapas lao.
  5. Default retention dekhna ho toh: git config --get gc.reflogExpire (khaali matlab default 90 din).
git reflog
git cat-file -p HEAD
git reset --hard HEAD@{1}
git branch rescue <hash>

Sources

git-scm.com docs aur Pro Git book, Git User's Survey 2010 (kernel.org wiki archive); demo outputs git 2.39 par asli repo se; 3 Nov 2026 ko check kiya.

Aise hi tech cases ke liye follow karo