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.ps1in PowerShell)
- Call
git status
What changes were made to this repository? - Restore the
foo.txtfile usinggit restore foo.txt - Call
git statusagain
What happened tofoo.txt? - Unstage the changes to
bar.txtusinggit restore --staged bar.txt - Call
git statusonce more
What happened tobar.txt? - Restore the
bar.txtfile usinggit restore bar.txt - Call
git statusonce 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 statusone last time
What happened tofoo.txt?
git statusgit log --onelinegit restoregit restore --staged