Git Step-10 : 기타 명령어
switch
git switch branch == git checkout branch
git switch -c branch = git checkout -b branch
git 2.23.0 버전부터 사용 가능
git switch -h
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 or diff3)
-d, --detach detach HEAD at named commit
-t, --track set upstream info for new branch
-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
restore
git restore file = working directory의 file 내용을 HEAD 커밋 기준으로 복원.
git restore –staged file = staged file을 unstaged 시켜서 working directory의 modified 상태로 변경시킨다.
만약 HEAD 기준으로 복원하고 싶다면 이 상태에서 git resotre 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 or diff3)
-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
Double Dot (..)
git log master..origin/master = master에는 없고 remote master에는 존재하는 커밋 보기
이외에도 ^ 또는 –not 옵션을 사용할 수 있습니다.
$ git log A..B
$ git log ^A B
$ git log B --not A
$ git log A B ^C
$ git log A B --not C
댓글남기기