Git commands
The ones that never quite stick, so I don’t have to re-google them.
| command | what it does |
|---|---|
git switch -c my-branch |
create and switch to a new branch |
git restore --staged file |
unstage a file (keep the changes) |
git restore file |
discard local changes to a file |
git commit --amend --no-edit |
add staged changes to the last commit |
git reset --soft HEAD~1 |
undo last commit, keep changes staged |
git stash / git stash pop |
shelve changes and bring them back |
git stash -u |
stash including untracked files |
git reflog |
history of where HEAD has been (recover “lost” commits) |
git cherry-pick <sha> |
apply a single commit onto the current branch |
git rebase -i HEAD~3 |
squash/reword the last 3 commits |
git bisect start |
binary-search commits to find a regression |
git log --oneline --graph --all |
readable branch graph |
git diff --staged |
see what’s actually about to be committed |
git branch -d branch |
delete a merged branch (-D to force) |