We all make mistakes. Sometimes we make changes we'd rather not have made, or accidentally stage changes we didn't intend to stage.
This is where git restore
comes into play.
- Run
source setup.sh
(or.\setup.ps1
in PowerShell)
- Call
git status
What changes were made to this repository? - Restore the
foo.txt
file usinggit restore foo.txt
- Call
git status
again
What happened tofoo.txt
? - Unstage the changes to
bar.txt
usinggit restore --staged bar.txt
- Call
git status
once more
What happened tobar.txt
? - Restore the
bar.txt
file usinggit restore bar.txt
- Call
git status
once more
What happened tobar.txt
? - Call
git log --oneline
Do you spot the tag? - Restore
foo.txt
's contents to their previous version usinggit restore -s v1.0.0 foo.txt
- Call
git status
one last time
What happened tofoo.txt
?
git status
git log --oneline
git restore
git restore --staged