@dimmus

Git - Undo

Undo local changes (uncommited)

Check files to undo:

git status

Undo changes in multiple files (all changed):

git restore . (git chekout .)

Undo only one file:

git restore <filename> (git checkout <filename>)

Undo commit (pushed)

Ceck you have a clean working tree:

git status

Check commit hash to undo:

git log --oneline

Undo pushed commit:

git revert 224bc7a --no-edit
git push

Undo commit (unpushed)

Undo last commit:

git reset --soft HEAD~

Undo last two commits:

git reset --soft HEAD~2

Undo multiple commits (pushed)

Get commit hash to start undo:

git log --oneline

Start rebase commit:

git rebase -i 58c2736

In opened vim file change appropriate keyword ‘pick’ (saved commit) to ‘d’ (deleted commit). Then save vim file (:wq).