Git guides
The ideas behind the fixes.
- git reset: soft, mixed and hard
- What the staging area is
- HEAD, HEAD~1 and HEAD@{1} explained
- Merge or rebase: which to use
- Git command cheat sheet from tested examples
Fix-it pages
- Undo the last commit but keep my changes
- Undo the last commit and throw the changes away
- Change the last commit message
- Add a forgotten file to the last commit
- Unstage a file I added by mistake
- Throw away my changes to one file
- Undo a commit that is already pushed
- Get back a commit after reset --hard
- Recover a branch I deleted
- Save unfinished work and switch branch
- Move a commit I made on the wrong branch
- Combine the last three commits into one
- Copy one commit to another branch
- Put my branch on top of the latest main
- Fix a merge conflict
- Undo a merge I just made
- Stop tracking a file but keep it on disk
- Find who changed a line and why
- See what I changed before I commit
- Rename a branch
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.