๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
BackEnd๐ŸŒฑ/Etc

์ž‘์—… ์ž„์‹œ ์ €์žฅํ•˜๊ธฐ IntelliJ์˜ Shelve

by dkswnkk 2023. 1. 13.

์„œ๋ก 

ํŠน์ • branch์—์„œ ์ž‘์—…์„ ํ•˜๋‹ค๊ฐ€ ๋‹ค๋ฅธ branch๋กœ ์ด๋™์„ ํ•ด์•ผ ํ•˜๋Š” ์ƒํ™ฉ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด checkout ์‹œ๋„

๊ทธ๋Ÿด ๋•Œ checkout์„ ํ†ตํ•ด branch๋ฅผ ์ด๋™์„ ์‹œ๋„ํ•˜๋ฉด ์œ„์™€ ๊ฐ™์ด commit ํ˜น์€ stash๋ฅผ ๋จผ์ € ํ•˜๋ผ๋Š” ๋ฌธ๊ตฌ๋ฅผ ๋งŽ์ด ๋ณด์…จ์„ ๊ฒ๋‹ˆ๋‹ค.

IntelliJ IDE๋ฅผ ํ†ตํ•ด checkout ์‹œ๋„
IntelliJ IDE๋ฅผ ํ†ตํ•ด checkout ์‹œ๋„

ํ˜น์€ IntelliJ IDE๋ฅผ ํ†ตํ•ด checkout๋ฅผ ์‹œ๋„ํ–ˆ์„ ๋•Œ๋Š” ์œ„์™€ ๊ฐ™์€ ์ฐฝ์ด ๋„์›Œ์ง€๋ฉฐ ๋ณ€๊ฒฝ ๋‚ด์—ญ์„ ๋จผ์ € ์ฒ˜๋ฆฌํ•˜๋„๋ก ์œ ๋„ํ•ฉ๋‹ˆ๋‹ค.

์ง€๊ธˆ๊นŒ์ง€ ์ €๋Š” git stash๋ฅผ ํ†ตํ•ด ์ž‘์—…์‚ฌํ•ญ์„ ์ž„์‹œ๋กœ ์ €์žฅํ–ˆ์œผ๋‚˜ ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์ธ IntelliJ์˜ Shelve๋ผ๋Š” ๊ธฐ๋Šฅ์„ ์•Œ๊ฒŒ ๋˜์–ด ์ •๋ฆฌ๋ฅผ ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

 IntelliJ Shelve

Commit -> ์ฒดํฌ ํ›„ ์šฐ์ธก๋งˆ์šฐ์Šค -> Shelve Changes

๋จผ์ € branch๋ฅผ checkout ํ•˜๊ธฐ ์ „ IntelliJ ์ขŒ์ธก์˜ Commit์„ ํ†ตํ•ด ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ €์žฅํ•  ํŒŒ์ผ๋“ค์„ ์ฒดํฌ๋ฐ•์Šค๋ฅผ ๋ˆŒ๋ ค ์ฒดํฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ํ›„ Shelve Changes๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

๋ณ€๊ฒฝ ๋‚ด์—ญ ๋‹ค์‹œ ํ™•์ธ -> SHELVE CHANGES

๊ทธ๋ฆฌ๊ณ  ๋ณ€๊ฒฝ ๋‚ด์—ญ์„ ๋‹ค์‹œ ํ™•์ธํ•œ ๋’ค ์šฐ์ธก ํ•˜๋‹จ์˜ SHELVE CHANGES ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

Shelf ๊ณต๊ฐ„์— ์ €์žฅ

๊ทธ๋Ÿฌ๋ฉด Shelf๋ผ๋Š” ๊ณต๊ฐ„์ด ์ƒ์„ฑ๋˜๋ฉฐ ์ด์ „ ์ž‘์—… ๋‚ด์šฉ๋“ค์ด ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ์ด์ œ ๋‹ค๋ฅธ branch๋กœ checkout ์‹œ๋„ ์‹œ์— ์ •์ƒ์ ์œผ๋กœ ์ด๋™์ด ๋ฉ๋‹ˆ๋‹ค.

์ด์ „ ์ž‘์—… ๋‚ด์šฉ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

๋งŒ์•ฝ ๋‹ค์‹œ ์›๋ž˜ ์ž‘์—…ํ•˜๋˜ branch๋กœ ๋Œ์•„์™€์„œ ์ž‘์—… ๋‚ด์šฉ๋“ค์„ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ๋ฅผ ์›ํ•œ๋‹ค๋ฉด Commit -> Shelf -> Unshelve๋ฅผ ํ†ตํ•ด ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์„œ ์ด์ „ ์ž‘์—… ๋‚ด์šฉ๋“ค Shelf์—์„œ Unshelve๋ฅผ ํ†ตํ•ด ๋ถˆ๋Ÿฌ์™”๋”๋ผ๋„ Shelf์— ์ €์žฅ๋œ ๋‚ด์—ญ๋“ค์€ ์ž๋™์œผ๋กœ ์ง€์›Œ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ง€์šฐ๊ณ  ์‹ถ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ง์ ‘ ์ˆ˜๋™์œผ๋กœ ์ง€์›Œ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ €์žฅํ•œ ๋‚ด์—ญ ์ œ๊ฑฐ

 

Git Stash์™€ IntelliJ Shelve ์ฐจ์ด

๊ณ„์†ํ•ด์„œ IntelliJ๋ผ๋Š” ๋‹จ์–ด๋ฅผ ๋ถ™์—ฌ์„œ ๋ˆˆ์น˜ ์ฑ„์‹  ๋ถ„๋„ ๊ณ„์‹œ๊ฒ ์ง€๋งŒ Shelve๋Š” Git์—์„œ ์ œ๊ณตํ•˜๋Š” ๋ช…๋ น์–ด๊ฐ€ ์•„๋‹Œ IntelliJ IDE์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ stash์™€ ๋‹ค๋ฅด๊ฒŒ git์œผ๋กœ ๊ด€๋ฆฌ๊ฐ€ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ๊ฐ€์žฅ ํฐ ์ฐจ์ด๋Š” stash ๊ฐ™์€ ๊ฒฝ์šฐ ๊ฐœ๋ณ„์ ์œผ๋กœ ์ €์žฅ์ด ๋˜์ง€ ์•Š๊ณ  ๋ชจ๋“  ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํ•œ ๋ฒˆ์— ์ž„์‹œ ์ €์žฅํ•˜์ง€๋งŒ Shelve ๊ฐ™์€ ๊ฒฝ์šฐ๋Š” ์›ํ•˜๋Š” ๊ฐœ๋ณ„ ํŒŒ์ผ ๋˜๋Š” ๋ฌถ์Œ์œผ๋กœ ์„ ํƒํ•˜์—ฌ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ œ ์ƒ๊ฐ์—๋Š” Shelve๊ฐ€ ๋” ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

์ฐธ๊ณ 

  1. https://stackoverflow.com/questions/28008139/git-stash-vs-shelve-in-intellij-
  2. ideahttps://www.jetbrains.com/help/idea/work-on-several-features-simultaneously.html#stash

๋Œ“๊ธ€