Git commands(diff, stash)
git diff branch_a branch_b
branch_a와 branch_b 의 차이를 터미널에 보여준다.
ex) git diff origin/master origin/feature_a
git stash
branch_a에서 작업을 하다가 다른 브랜치로 넘어가야 할 때
작업한 내용을 임시로 백업할 때 사용한다.
commit을 해도 되긴하지만,
작업 도중인 중간 결과물을 commit 할 때에는 커밋 메시지도 뭐라고 넣을지 애매하고
취소할 때 귀찮기 때문에 stash가 용이하다.
commit은 local에 변경 내용을 반영시키는 절차라서,
아직 반영 시킬 준비가 안 됐을 때 stash를 쓰면 용이하다.
git stash list
백업된(stashed) 내용을 보여준다.
git stash apply stash@{0) (stash 이름으로 가져오기)
or
git stash apply 0 (stash 인덱스 번호로 가져오기)
stash된 내용을 다시 불러올 때 사용한다.
apply 뒤에 인자를 부여하지 않고 git stash apply만 입력하면 가장 최근의 stashed 백업을 가져온다.
git stash drop stash@{0} (stash 이름으로 삭제)
or
git stash drop 0 (인덱스 번호로 삭제)
특정 stash를 삭제할 때 사용
git stash branch new_branch
stash된 내용으로 새로운 브랜치(new_branch)를 생성할 때 사용.
<참고 링크>
https://backlog.com/git-tutorial/kr/
https://itholic.github.io/git-stash/
댓글
댓글 쓰기