Git Stash๋ ํ์ฌ ์์ ์ค์ธ ๋ณ๊ฒฝ ์ฌํญ์ ์์๋ก ์ ์ฅ(stash)ํด๋๊ณ , ๊นจ๋ํ ์ํ์์ ๋ค๋ฅธ ๋ธ๋์น๋ก ์ด๋ํ๊ฑฐ๋ ๋ณ๊ฒฝ ์ฌํญ์ ๋ณด๋ฅํ ๋ ์ฌ์ฉํ๋ ๊ธฐ๋ฅ์ด๋ค.
git stash
๐ Tracked ํ์ผ์ ๋ณ๊ฒฝ ์ฌํญ๋ง ์ ์ฅํ๊ณ , Untracked ํ์ผ์ ์ ์ฅ๋์ง ์์.
git stash push -m "์์
๋ด์ฉ ์ค๋ช
"
๐ ์ฌ๋ฌ ๊ฐ์ stash๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ฝ๊ฒ ๋ฉ์์ง๋ฅผ ์ถ๊ฐํ ์ ์์.
git stash -u # (Untracked files ํฌํจ)
git stash -a # (Untracked + Ignored files ํฌํจ)
git stash list
๐ ์ ์ฅ๋ stash ๋ชฉ๋ก์ด ๋ณด์ธ๋ค.
stash@{0}: WIP on main: 1234567 Update readme
stash@{1}: WIP on dev: abcdef0 Fix bug
stash@{2}: WIP on feature: 789abcd New UI
git stash apply
๐ ์ต๊ทผ stash๋ฅผ ์ ์ฉํ์ง๋ง stash ์์ฒด๋ ์ญ์ ๋์ง ์์
git stash apply stash@{2}
๐ stash@{2}์ ๋ด์ฉ์ ์ ์ฉํจ
git stash pop
๐ ๊ฐ์ฅ ์ต๊ทผ stash ์ ์ฉ ํ ์๋ ์ญ์ ๋จ
git stash pop stash@{1}
๐ stash@{1}์ ์ ์ฉํ๊ณ ์ญ์ ํจ
git stash drop stash@{1}
๐ stash@{1}๋ง ์ญ์ ๋จ
git stash drop
๐ stash@{0}์ ์ญ์ ํ๊ณ , ๋๋จธ์ง stash๋ค์ด ํ ์นธ์ฉ ์์ผ๋ก ์ด๋ํจ
git stash clear
๐ ๋ชจ๋ stash๋ฅผ ์ญ์ (๋ณต๊ตฌ ๋ถ๊ฐ)
git stash show -p stash@{0}
๐ stash@{0}์ ๋ณ๊ฒฝ ์ฌํญ์ ์์ธํ ํ์ธ
git checkout stash@{0} -- ํ์ผ๋ช
๐ stash์์ ํน์ ํ์ผ๋ง ์ฒดํฌ์์ํ์ฌ ๋ณต์ํ ์ ์์
git stash branch ์๋ก์ด_๋ธ๋์น๋ช
stash@{0}
๐ stash ๋ด์ฉ์ ์๋ก์ด ๋ธ๋์น์์ ๋ณต์ํ๊ณ ๊ธฐ์กด stash๋ ์ญ์ ๋จ
| ๊ธฐ๋ฅ | ๋ช ๋ น์ด |
|---|---|
| Stash ์ ์ฅ | git stash |
| ๋ฉ์์ง๋ฅผ ๋ถ์ฌ ์ ์ฅ | git stash push -m "๋ฉ์์ง" |
| Untracked ํ์ผ๊น์ง ์ ์ฅ | git stash -u / git stash -a |
| Stash ๋ชฉ๋ก ํ์ธ | git stash list |
| ๊ฐ์ฅ ์ต๊ทผ stash ์ ์ฉ | git stash apply |
| ํน์ stash ์ ์ฉ | git stash apply stash@{n} |
| ๊ฐ์ฅ ์ต๊ทผ stash ์ ์ฉ ํ ์ญ์ | git stash pop |
| ํน์ stash ์ ์ฉ ํ ์ญ์ | git stash pop stash@{n} |
| ํน์ stash ์ญ์ | git stash drop stash@{n} |
| ๋ชจ๋ stash ์ญ์ | git stash clear |
| Stash ๋ด์ฉ ํ์ธ | git stash show -p stash@{n} |
| ํน์ ํ์ผ๋ง ๋ณต์ | git checkout stash@{n} -- ํ์ผ๋ช
|
| ์๋ก์ด ๋ธ๋์น์์ Stash ์ ์ฉ | git stash branch ์๋ก์ด_๋ธ๋์น stash@{n} |