git tips: undo & clean

2020-01-19

 | 

~1 min read

 | 

121 words

Commonly used Git commands that are worth remembering (or having a quick reference like this one for):

  1. Undo your last commit: git reset HEAD~1 (Stack Overflow)
  2. Undo your last commit, but leave changes staged: git reset --soft HEAD~
  3. Undo your last commit, but leave it in history: git revert HEAD~
  4. Undo all current changes and reset the environment to the last commit: git reset --hard HEAD
  5. Remove all untracked files: git clean -f2
  6. Remove untracked directories, too: git clean -f -d

Resources


Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!