📎 Webclip
Oh shit, git!
Git is hard because it is easy to make mistakes and hard to find the right fix when you are already stuck. The page offers practical recovery steps for common bad situations, written in plain English rather than as a complete reference or a beginner tutorial.
Reading notes#
git reflogshows every Git action across branches and can be used to find the state before things broke, thengit reset HEAD@{index}can return to it.git commit --amendlets you add a small fix to the last commit after making the change.git commit --amendalso changes the message on the last commit.- If a commit landed on
masterby mistake, create a branch from the current state, resetmasterback, and keep the commit on the new branch. - If a commit was made on the wrong branch, you can reset softly, stash the changes, switch branches, pop the stash, and commit again on the right branch.
git diff --stagedshows a diff for files already added to the staging area.- If you give up, delete the repo and clone it again.
