Git
A cheatsheet by @nathan-appere|Refreshed 7 months ago.Refresh|View source on Github

Undo last commit

Undo last commit

git reset --soft HEAD~1
git reset

Undo the last commit + unstage everything.

git stash; git reset --soft HEAD~1; git stash pop;

Stash changes + undo the last commit + re-add changes.

Diff staging

Diff staging

git diff --staged

Add new file as unstaged

Add new file as unstaged

git add -n

Warning: this is incompatible with stashing unstaged files somehow.

Stash unstaged & untracked

Stash unstaged & untracked

git stash -k -u

Stash unstaged files & untracked files (-u).