Chapter 8Git & GitHub~1 min read
Changes Undo करणे
Mistakes Fix करायला शिका
Git मधला सर्वात powerful feature म्हणजे undo. Commit केलेलं चुकीचं असलं, staged files unstage कराव्या लागल्या, किंवा काही दिवसांपूर्वीचा code परत हवा असला — Git सगळं handle करतो.
Unstage आणि Discard changes
bash
# Staged file unstage करा (commit होणार नाही)
git restore --staged index.html
# File च्या unsaved changes discard करा (careful!)
git restore index.html
# सगळ्या unstaged changes discard करा
git restore .git revert vs git reset
Commits undo करा
bash
# git revert — safe! नवीन commit बनवतो जो undo करतो
# GitHub वर push केलेल्या commits साठी हाच वापरा
git revert abc1234
# git reset — local commits undo करा
# --soft: commit undo, changes staged राहतात
git reset --soft HEAD~1
# --mixed (default): commit undo, changes unstaged
git reset HEAD~1
# --hard: commit undo + changes delete (careful!)
git reset --hard HEAD~1git stash — तात्पुरते Changes Save करा
Stash workflow
bash
# Current changes stash करा (save करा temporarily)
git stash
# Stash list बघा
git stash list
# Stash परत apply करा
git stash pop # apply + stash delete
git stash apply # apply, stash ठेवतो
# Stash message सोबत
git stash push -m "WIP: dark mode"📌
git reset --hard चुकून run केलं तर `git reflog` वापरा — सगळ्या recent HEAD positions दिसतात आणि lost commits परत मिळवता येतात!
✅ Key Points — लक्षात ठेवा
- ▸git restore — working directory changes undo
- ▸git revert — safe undo (pushed commits साठी)
- ▸git reset — local commits undo (3 modes)
- ▸git stash — changes temporarily park करा
- ▸git reflog — emergency recovery tool
0/10 chapters पूर्ण