« Back to Index

Git: restore and switch to replace git checkout

View original Gist on GitHub

Tags: #git

git restore and git switch to replace git checkout.md

https://www.banterly.net/2021/07/31/new-in-git-switch-and-restore/

git switch -c/--create <branch>
git switch -d/--detach <commit|tag>
git restore -- test.txt               # restores uncommitted changes to indexed version in the current branch.
git restore --source=main -- test.txt # restores committed changes to version from the specified source (branch, tag or commit).