์žฌ๋ฐŒ๊ฒŒ ํ•ฉ์‹œ๋‹ค

๊ธฐ๋กํ•˜๊ธฐ, ๊ฐ€์‹œํ™”ํ•˜๊ธฐ

git ๋งˆ์Šคํ„ฐ

remote์— pushํ•œ ์ปค๋ฐ‹์€ rebase ํ•˜์‹œ๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค(๊ผฌ์ธ git ํ‘ผ ๊ธฐ๋ก)

์€๋˜๋”” 2022. 9. 4. 21:27

๋“œ๋””์–ด ์ •์ƒ์ ์ธ ๋ฐฉ๋ฒ•๋“ค๋กœ ๊ผฌ์ธ git์„ ํ’€์–ด๋ƒˆ๋‹ค ์šฐํ•˜ํ•˜

๋ฌธ์ œ ์ƒํ™ฉ ์ •๋ฆฌ(์ˆœ์„œ๋Œ€๋กœ)

1. local/feature/modal์„ remote์— push

2. origin/feature/modal โžก๏ธ origin/master pull request

3. ๋‹ค๋ฅธ ํŒ€์›์ด ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜์—์„œ ์ž‘์—… ํ›„ origin/master๋กœ merge

 

pr์—์„œ ๋ฐ›์€ ํ”ผ๋“œ๋ฐฑ์„ ๋ฐ˜์˜ํ•ด local/feature/modal ๋ธŒ๋žœ์น˜์—์„œ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๊ณ ์ž ํ–ˆ๋‹ค.

๊ทธ ์ „์— ๋™๋ฃŒ์˜ ์ž‘์—…์„ pull ๋ฐ›๊ธฐ ์œ„ํ•ด local/master๋กœ ์ด๋™, git pull origin master ์„ ์‹คํ–‰ํ–ˆ๋‹ค.

์ดํ›„ ๋‹ค์‹œ local/feature/modal ๋ธŒ๋žœ์น˜๋กœ ๋Œ์•„์™€, pull ๋ฐ›์€ ์ดํ›„์˜ ์ปค๋ฐ‹๋ถ€ํ„ฐ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด local/master์— ๋Œ€ํ•ด rebase๋ฅผ ํ–ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค.

์ž‘์—…์„ ๋งˆ์นœ ๋‹ค์Œ push๋ฅผ ํ•˜๋ ค๊ณ  ํ•˜๋‹ˆ ๋จผ์ € pull์„ ๋ฐ›์œผ๋ผ๋Š” ์—๋Ÿฌ๊ฐ€ ๋–ด๋‹ค. ๊ทธ๋ž˜์„œ git graph๋ฅผ ์‚ดํŽด๋ณด๋‹ˆ, ์œ„์—์„œ ๋ณด์ด๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋™์ผํ•œ ๋‚ด์šฉ์˜ ๋‹ค๋ฅธ ์ปค๋ฐ‹ ์•„์ด๋””๋ฅผ ๊ฐ€์ง„ ์ปค๋ฐ‹๋“ค ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. rebase ๊ณผ์ •์—์„œ ๋ญ”๊ฐ€ ์ž˜๋ชป๋œ ๋“ฏํ•˜๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

1. pull request ์ดํ›„ ์ƒˆ๋กœ ์ƒ์„ฑํ–ˆ๋˜ commit๋“ค์„ ์ทจ์†Œ

2. tmp ๋ธŒ๋žœ์น˜๋ฅผ ํŒŒ ์ƒˆ๋กœ ์ž‘์—…ํ•œ ์ฝ”๋“œ๋“ค์„ ์˜ฎ๊ฒผ๋‹ค. tmp ๋ธŒ๋žœ์น˜์—์„œ stash๋กœ ์ฝ”๋“œ๋ฅผ ๋ณด๊ด€ํ–ˆ๋‹ค.

3. feature/modal ๋ธŒ๋žœ์น˜๋กœ ๋Œ์•„์™€ git reset์„ ํ†ตํ•ด, origin/feature/modal์˜ ๋งˆ์ง€๋ง‰ ์ปค๋ฐ‹ ์œ„์น˜๋กœ ๋ธŒ๋žœ์น˜๋ฅผ ์ด๋™์‹œ์ผฐ๋‹ค.( git reset --hard bf98c0d6) ์ฆ‰, rebase๋ฅผ ์ทจ์†Œํ•จ

4. tmp ๋ธŒ๋žœ์น˜์—์„œ apply stash

5. ๊ทธ๋Œ€๋กœ ๋‹ค์‹œ feature/modal๋กœ ๋„˜์–ด์™€ ์ƒˆ๋กœ์šด ์ฝ”๋“œ๋“ค commit ํ›„ push

 

 

master ๋ธŒ๋žœ์น˜์—์„œ git pull์„ ๋ฐ›์€ ๋‹ค์Œ, ํ•ด๋‹น ์ปค๋ฐ‹์—์„œ๋ถ€ํ„ฐ ๊ธฐ๋Šฅ ๋ธŒ๋žœ์น˜์˜ ์ž‘์—…์„ ์žฌ๊ฐœํ•˜๊ธฐ ์œ„ํ•ด git rebase๋ฅผ ์‚ฌ์šฉํ•ด์™”๋‹ค. ๊ธฐ๋Šฅ ๋ธŒ๋žœ์น˜๊ฐ€ ์›๊ฒฉ์ €์žฅ์†Œ์— Push๋œ ์ ์ด ์—†์„ ๊ฒฝ์šฐ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์•˜๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ด๋ฒˆ์ฒ˜๋Ÿผ ์ด๋ฏธ push๋œ ๋ธŒ๋žœ์น˜์ธ ๊ฒฝ์šฐ rebase๊ฐ€ ์ค‘๋ณต๋œ ์ปค๋ฐ‹์„ ์ƒ์„ฑํ•ด ๋ฌธ์ œ๋ฅผ ์ผ์œผํ‚จ๋‹ค. rebase ๋‚จ๋ฐœ ๊ธˆ์ง€..

 

๊ทธ๋ ‡๋‹ค๋ฉด ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ๋ฒ•์€?

 

์ด ๊ธ€์„ ์ž‘์„ฑํ•˜๋‹ค ์ž„์‹œ์ €์žฅ ํ•ด๋†“๊ณ  ์•ฝ 14์ผ๋งŒ์— ๋˜‘๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ–ˆ๋‹ค. ์•„๋ž˜ ๊ธ€์—์„œ ๋‚˜์™€ ๊ฐ™์€ ์งˆ๋ฌธ์„ ํ•œ ์‚ฌ๋žŒ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

https://stackoverflow.com/questions/20101994/how-to-git-pull-from-master-into-the-development-branch

 

How to "git pull" from master into the development branch

I have a branch called "dmgr2" in development, and I want to pull from the master branch (live site) and incorporate all the changes into my development branch. Is there a better way to d...

stackoverflow.com

 

๊ฒฐ๋ก ์€ ๊ฒฐ๊ตญ rebase๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

 

1. ๊ธฐ๋Šฅ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™
2. git rebase origin
3. conflict๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๋ฉด ํ•ด๊ฒฐ 
4. git rebase --continue

๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋˜ ๋ฐฉ๋ฒ•๊ณผ์˜ ์ฐจ์ด์ ์€ rebaseํ•˜๋Š” ๋ธŒ๋žœ์น˜๋‹ค.

๊ธฐ์กด์—๋Š” local/master์— ๋Œ€ํ•ด rebase๋ฅผ ํ–ˆ๋‹ค. ์ƒˆ ๋ฐฉ๋ฒ•์˜ ๊ฒฝ์šฐ origin์— ๋Œ€ํ•ด ์ง์ ‘ rebase๋ฅผ ํ–ˆ๋‹ค.

 

conflict ๋‚œ ํŒŒ์ผ์„ ์ˆ˜์ •ํ–ˆ๋”๋‹ˆ ํ•ด๋‹น ํŒŒ์ผ์ด ํฌํ•จ๋œ ์ปค๋ฐ‹์˜ ์ปค๋ฐ‹๋ฉ”์‹œ์ง€๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ์ฐฝ์ด ๋–ด๋‹ค.  ๊ธฐ์กด ์ปค๋ฐ‹์— rebase๊ฐ€ ๋ฐ˜์˜๋œ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹๋“ค์ด ๋งŒ๋“ค์–ด์ง€๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค. ์ด๋ฏธ ๋ฆฌ๋ชจํŠธ์— push๋ฅผ ํ–ˆ๋˜ ์ƒํƒœ์˜€์–ด์„œ, ๊ทธ๋ƒฅ ํ•ด๋‹น ๋ฆฌ๋ชจํŠธ ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•œ ํ›„ rebase๊ฐ€ ๋ฐ˜์˜๋œ ์ปค๋ฐ‹๋“ค์„ ๋‹ค์‹œ pushํ–ˆ๋‹ค.

 

๋‚จ์€ ์˜๋ฌธ

๊ธฐ๋Šฅ ๋ธŒ๋žœ์น˜ ์ž‘์—… ๋„์ค‘์— pull์„ ๋ฐ›์•„์•ผ ํ•จ

+ ํ•ด๋‹น ๊ธฐ๋Šฅ ๋ธŒ๋žœ์น˜๊ฐ€ ๋ฆฌ๋ชจํŠธ์— push๋œ ์ ์ด ์žˆ์Œ

 

์ด๋•Œ ๋ฌธ์ œ ์—†์ด ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์€?


๊ทธ๋ž˜๋„ ์ž์„ธํžˆ ๊ธฐ๋กํ•ด ๋‘์—ˆ๋”๋‹ˆ ๋น„์Šทํ•œ ๋ฌธ์ œ๋ฅผ ๋งˆ์ฃผํ–ˆ์„ ๋•Œ ๋ณต๊ธฐ๊ฐ€ ์ž˜๋˜์–ด์„œ ์ข‹๋‹ค.