Sample workflow to undo changes
https://www.lukeko.com/35/sample-workflow-to-undo-changes 0Understand this simple workflow to properly understand how revert
and reset
works
~/code/gitfaffing % pico hello.txt
~/code/gitfaffing % git init
~/code/gitfaffing % git add .
~/code/gitfaffing % git commit -m "init"
~/code/gitfaffing % pico hello.txt
~/code/gitfaffing % git commit -a -m "first edit of hello.txt"
~/code/gitfaffing % pico hello.txt
~/code/gitfaffing % git commit -a -m "second edit of hello.txt"
~/code/gitfaffing % git log --oneline
* 57531cf (HEAD -> master) second edit of hello.txt
* d49fe1a first edit of hello.txt
* 4755417 init
~/code/gitfaffing % git revert --no-commit HEAD~2..
~/code/gitfaffing % more hello.txt
Initial content
~/code/gitfaffing % git commit -m "back to the intial hello text"
~/code/gitfaffing % git log --oneline
* 3b965f4 (HEAD -> master) back to the intial hello text
* 57531cf second edit of hello.txt
* d49fe1a first edit of hello.txt
* 4755417 init
~/code/gitfaffing % git reset --hard 4755417
~/code/gitfaffing % git log --oneline
* 4755417 (HEAD -> master) init