Skip to content

Instantly share code, notes, and snippets.

@LeoHeo
Last active June 22, 2016 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeoHeo/97350ffa8f615f13b67616ad56dcded7 to your computer and use it in GitHub Desktop.
Save LeoHeo/97350ffa8f615f13b67616ad56dcded7 to your computer and use it in GitHub Desktop.

git stash

git stash에 대해서 git-scm은 아래와 같이 설명을 한다.

Stashing
당신이 어떤 프로젝트에서 한 부분을 담당하고 있다고 하자. 그리고 여기에서 뭔가 작업하던 일이 있고 다른 요청이 들어와서 잠시 브랜치를 변경해야 할 일이 생겼다고 치자. 아직 완료하지 않은 일을 커밋하는 것은 좀 껄끄럽다. 이런 상황에서는 커밋하지 않고 나중에 다시 돌아와서 작업을 다시 하고 싶을 것이다. 이 문제는 git stash라는 명령으로 해결할 수 있다. Stash 명령을 사용하면 워킹 디렉토리에서 수정한 파일만 저장한다. Stash는 Modified이면서 Tracked 상태인 파일과 Staging Area에 있는 파일들을 보관해두는 장소다. 아직 끝나지 않은 수정사항을 스택에 잠시 저장했다가 나중에 다시 적용할 수 있다.

사용법

stashing

현재 상태 stashing 하기(아래는 tracked하는것들만 git stash)

$ git stash

untracked까지 모두 stashing하기

$ git stash save -u

list

$ git stash list

apply

저장된 stashing을 부를때 사용

가장 최근것 apply

$ git stash apply

index나 이름으로도 apply가능

$ git stash apply --index
$ git stash apply stash@{index}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment