let's get IT with DAVINA ๐Ÿ’ป

Git [merge] ๋ณธ๋ฌธ

DEV_IN/Git&Github

Git [merge]

๋‹ค๋นˆ์น˜์ฝ”๋“œ๐Ÿ’Ž 2023. 2. 8. 18:00

merge ๋ฐฉ๋ฒ•

๊ธฐ๋Šฅ ๊ฐœ๋ฐœ์ด ๋๋‚˜๋ฉด ๋ธŒ๋žœ์น˜๋ฅผ main ๋ธŒ๋žœ์น˜์™€ ํ•ฉ์น  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋จธ์ง€๋œ feature ๋ธŒ๋žœ์น˜๋Š” ์ด๋ฏธ dev ๋ธŒ๋žœ์น˜์— ๊ธฐ๋ก์ด ์™„๋ฒฝํ•˜๊ฒŒ ๋‚จ์•„์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ตณ์ด ๋‚จ๊ฒจ๋‘˜ ์ด์œ ๊ฐ€ ์—†์–ด ์‚ญ์ œ๋ฅผ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ pull request๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ๋งˆ๋ฌด๋ฆฌ๋˜๋ฉด, ๋ธŒ๋žœ์น˜๋ฅผ ์‚ญ์ œํ•˜๋Š” ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์‰ฝ๊ฒŒ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋กœ์ปฌ์—์„œ merge ์™„๋ฃŒ๋œ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ ๋ฐฉ๋ฒ•

git branch -d ๋ธŒ๋žœ์น˜๋ช…

//merge์•ˆํ•œ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ
git branch -D ๋ธŒ๋žœ์น˜๋ช…

case 1. ๊ฐ ๋ธŒ๋žœ์น˜์— ์‹ ๊ทœ commit์ด ์žˆ๋Š” ๊ฒฝ์šฐ => 3 way merge

git switch main //๋ฉ”์ธ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™
git merge feat //feat ๋ธŒ๋žœ์น˜๋ฅผ main๋ธŒ๋žœ์น˜๋กœ ๋ณ‘ํ•ฉ

  • ์ค‘์‹ฌ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•ด์„œ
  • git merge [์ƒˆ๋กœ์šด branch๋ช…]
  • ๋ชจ๋“  ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋ฐ˜์˜๋œ๋‹ค!

case 2. ๊ธฐ์ค€ main branch์—๋Š” ์‹ ๊ทœ commit์ด ์—†๊ณ  ์ƒˆ๋กœ ์ƒ์„ฑํ•œ ๋ธŒ๋žœ์น˜์—๋งŒ ์‹ ๊ทœ commit์ด ์žˆ๋Š” ๊ฒฝ์šฐ ⇒ fast-forward merge

  • ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜, ๋„ˆ๊ฐ€ mainํ•ด๋ผ!

case 3. git rebase & merge

  • ์ƒˆ๋กœ์šด branch๋กœ ์ด๋™ํ•ด์„œ
  • git rebase [์ค‘์‹ฌ ๋ธŒ๋žœ์น˜๋ช…]
  • ์ค‘์‹ฌ ๋ธŒ๋žœ์น˜๋กœ ์ด๋™ํ•ด์„œ
  • git merge [์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜๋ช…]
  • ๋ชจ๋“  ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ๋ฐ˜์˜๋œ๋‹ค1

case 4. squash & merge

  • ๋ชจ๋“  ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋ฐ˜์˜๋˜๋Š”๊ฒŒ ์•„๋‹Œ ์ตœ์ข… ๊ฒฐ๊ณผ๋ฌผ๋งŒ ๊น”๋”ํ•˜๊ฒŒ ๋”ฑ!
  • git merge --squash [์ƒˆ ๋ธŒ๋žœ์น˜]

'DEV_IN > Git&Github' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Git VS Github  (0) 2023.02.08
Git Flow  (4) 2023.02.08
Github  (0) 2023.02.08
Git [๋‚ด ์‹ค์ˆ˜ ๋ณต๊ตฌํ•˜๊ธฐ] ๊ณผ๊ฑฐ๋กœ ์“ฉ ๐Ÿ’จ  (4) 2023.02.08
Git [installation & branch ์ƒ์„ฑ]  (0) 2023.02.08
Comments