[git] git checkout

dev stefanCho·2021년 8월 4일
0

git

목록 보기
2/14

과거의 브랜치로 돌아가는 방법

git checkout -		 # git checkout @{-1}의 shorthand 이다.
git checkout @{-N} 	 # n번재 previous branch로 돌아간다.

git reflog에서 N번째를 찾을 수 있다.
git reflog에서 checkout: moving from branch_a to branch_b 를 카운트해서 적용한다.

ex) git reflog로 들어갔는데

HEAD@{0}: checkout: moving from branch_d to branch_e
HEAD@{1}: checkout: moving from branch_c to branch_d
HEAD@{2}: checkout: moving from branch_b to branch_c
HEAD@{3}: commit: [WINK-3890] code reducer에 categoryTag 추가
HEAD@{4}: checkout: moving from branch_a to branch_b

라고 하면, N이 3이어야지 branch_b 로 이동한다.

Ref

Stack overflow

profile
Front-end Developer

0개의 댓글