“Git undo” or the art of rolling back

Relax! Git makes it easy to get back seemingly lost work and dig yourself out of even the most delicate situations.
All videos in one download
627 MB
All sample repos in one download
1.02 MB
Welcome!
2 mins
Undoing ongoing edits ✋
Undoing an edit to the working copy
4 mins
Undoing an edit to the index and working copy
2 mins
Undoing an edit to the index only
4 mins
Undoing commits🧞‍♂️
Still with reset but…
4 mins
The --soft and --mixed modes
5 mins
Differences between --keep, --merge and --hard
4 mins
The --keep mode
2 mins
The --merge mode
2 mins
The --hard mode
2 mins
So this is swell, but how about some actual use cases? 🤔
You can (un)do pretty much anything
2 mins
I committed too fast
4 mins
Splitting my latest commit
3 mins
Squashing recent commits as one
3 mins
I should have branched off sooner
3 mins
Wiping the slate clean
2 mins
Undoing is neat, but can I “redo” if I screw up? 😨
Sure you can: the reflog remembers what you forgot
3 mins
Log vs Reflog
1 min
How is our reflog built from the HEAD?
6 mins
How is our reflog built from branch tips?
3 mins
So I can never lose anything, right?
1 min
reflog + reset: back to the future
2 mins
Works with everything! 🦄
commit, reset, merge, rebase, pull…
1 min
Undoing a merge
4 mins
Undoing a rebase
6 mins
Undoing a pull
1 min
Undoing a merge-mode pull
4 mins
Undoing a rebase-mode pull
2 mins
Git revert: not so fast! 🤢
Git revert carelessly pollutes the history
2 mins
And we’re done! 😭
Want more video courses?
2 mins
Further reading…