🔀Git Reset
Also known as git reset, git reset --hard, Reset a Branch
Moving a branch back to an earlier commit. Later commits drop out of it.
Think of it like
Think of it like moving a bookmark back a few pages. The pages after it no longer count.
Example
Emma made two messy commits she has not pushed. She runs git reset --soft HEAD~2 and commits again as one.
Why it matters
It cleans up local work before you share it.
Definition
Example code
console
$ git reset --soft HEAD~1
$ git status --short
M index.htmlCommon mistake
Key takeaways
- 1Moves the branch. Back to the commit you name.
- 2Three modes. Soft, mixed or hard.
- 3Local work only. Never reset what others pulled.