File tree Expand file tree Collapse file tree 1 file changed +86
-0
lines changed
Expand file tree Collapse file tree 1 file changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+ # 깃 Stash 명령어
2+
3+ ## Stash 사용 상황
4+ - 긴급 버그 핫픽스
5+ - 기능 개발 중인데, 갑자기 프로덕션 긴급 버그를 고쳐야 할 때
6+ - 현재 작업 중인 변경사항을 커밋하기엔 완성도가 낮거나 커밋 로그가 어수선해질 때
7+
8+ <br >
9+
10+ - 브랜치 전환 전 작업 보관
11+ - 다른 브랜치로 급히 이동해야 할 때, 워킹 디렉토리를 깨끗하게 정리하고 싶을 때
12+
13+ <br >
14+
15+ - 리베이스나 머지 전 준비
16+ - 안전하게 리베이스(rebase) 또는 머지(merge)하기 위해, 로컬 수정사항을 임시로 치워두고 충돌 최소화
17+
18+ <br >
19+
20+ ## 사용 플로우
21+ #### 1. 변경사항 임시 저장
22+
23+ ``` shell
24+ git stash
25+
26+ &
27+
28+ git stash push -m " 메세지"
29+
30+ ```
31+
32+ <br >
33+
34+ #### 2. 저장된 stash 목록 확인
35+
36+ ``` shell
37+ git stash list
38+
39+ // ex
40+ % git stash list
41+ stash@{0}: WIP on test: test
42+ stash@{1}: WIP on test: test
43+ stash@{2}: WIP on test: test
44+ stash@{3}: WIP on test: test
45+
46+ ```
47+
48+ <br >
49+
50+ #### 3. 원하는 스태시 적용 (apply & pop)
51+
52+ ``` shell
53+ git stash apply stash@{0}
54+
55+ &
56+
57+ git stash pop stash@{0}
58+ ```
59+ - apply (적용만, 스태시는 그대로 남김)
60+ - pop (적용 + 자동 삭제)
61+ - 충돌 발생 시 일반 머지 충돌 해결 절차대로 수정 후 커밋
62+ <br >
63+
64+ #### 4. 스태시 삭제
65+
66+ ``` shell
67+ git stash drop stash@{0}
68+
69+ &
70+
71+ git stash clear
72+ ```
73+ - drop : 별도로 하나씩 삭제
74+ - clear : 전체 삭제
75+
76+ <br >
77+
78+ #### 5. 변경 사항 커밋
79+
80+ ``` shell
81+ git add .
82+ git commit -m " 메세지"
83+
84+ ```
85+
86+ <br >
You can’t perform that action at this time.
0 commit comments