↓ Ir para o conteúdo principal

← todas as notas

📎 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 reflog shows every Git action across branches and can be used to find the state before things broke, then git reset HEAD@{index} can return to it.
  • git commit --amend lets you add a small fix to the last commit after making the change.
  • git commit --amend also changes the message on the last commit.
  • If a commit landed on master by mistake, create a branch from the current state, reset master back, 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 --staged shows a diff for files already added to the staging area.
  • If you give up, delete the repo and clone it again.