Git 2.23
부터 checkout
을 대체하는 switch
와 restore
가 도입되었다고 한다.
Switch branches or restore working tree files
checkout
의 기능이 각각 switch
와 restore
로 분리 된 것이다.
브랜치를 변경한다.
git switch branch명
-c 옵션을 추가하면 생성하면서 변경 할 수 있다.
$ git switch -help
usage: git switch [<options>] [<branch>]
-c, --create <branch>
create and switch to a new branch
-C, --force-create <branch>
create/reset and switch to a branch
--guess second guess 'git switch <no-such-branch>'
--discard-changes throw away local modifications
-q, --quiet suppress progress reporting
--recurse-submodules[=<checkout>]
control recursive updating of submodules
--progress force progress reporting
-m, --merge perform a 3-way merge with the new branch
--conflict <style> conflict style (merge, diff3, or zdiff3)
-d, --detach detach HEAD at named commit
-t, --track[=(direct|inherit)]
set branch tracking configuration
-f, --force force checkout (throw away local modifications)
--orphan <new-branch>
new unparented branch
--overwrite-ignore update ignored files (default)
--ignore-other-worktrees
do not check if another worktree is holding the given ref
파일을 복원한다
git restore 파일명
$ git restore -help
usage: git restore [<options>] [--source=<branch>] <file>...
-s, --source <tree-ish>
which tree-ish to checkout from
-S, --staged restore the index
-W, --worktree restore the working tree (default)
--ignore-unmerged ignore unmerged entries
--overlay use overlay mode
-q, --quiet suppress progress reporting
--recurse-submodules[=<checkout>]
control recursive updating of submodules
--progress force progress reporting
-m, --merge perform a 3-way merge with the new branch
--conflict <style> conflict style (merge, diff3, or zdiff3)
-2, --ours checkout our version for unmerged files
-3, --theirs checkout their version for unmerged files
-p, --patch select hunks interactively
--ignore-skip-worktree-bits
do not limit pathspecs to sparse entries only
--pathspec-from-file <file>
read pathspec from file
--pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character