์ž‘์—… ํ•˜๋Š” ์™€์ค‘์— develop branch๋ฅผ origin์—์„œ pullํ•˜๋ ค๋‹ค๊ฐ€ Fast Forward if possible์ด๋ผ๋Š” ๊ฒƒ์„ ๋ณด๊ฒŒ๋˜์—ˆ๋‹ค. ์ด๊ฑด ๋ฌด์—‡์ธ๊ฐ€?

์•Œ์•„๋ณผ ๋…€์„

git kraken์—๋Š” pull ๋ฒ„ํŠผ ์•„๋ž˜์— ์˜ต์…˜์„ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ Fast forward๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณด๋Š” ๊ฒƒ์ด ์ด ํฌ์ŠคํŒ…์˜ ๋ชฉํ‘œ์ด๋‹ค.

Objective

  1. Hotfix branch๋ฅผ ๋งŒ๋“ค์–ด ๊ธ‰ํ•œ ๋ถˆ์„ ๋ˆ ๋’ค, master์— ๋ฐ˜์˜ํ•œ๋‹ค.
  2. ๊ธฐ์กด์— ์ž‘์—…ํ•˜๊ณ  ์žˆ๋˜ issue๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  master์— ๋ฐ˜์˜ํ•œ๋‹ค.

git๋ฌธ์„œ์—์„œ๋Š” ์œ„ ๋‘๊ฐ€์ง€ ์ž‘์—…์„ ํ•˜๋ฉด์„œ fast forward์™€ merge์— ๋Œ€ํ•ด ์„ค๋ช…ํ•œ๋‹ค.

์ผ๋‹จ ์ดˆ๊ธฐ ์ƒํƒœ๋Š” 3๊ฐœ์˜ ์ปค๋ฐ‹์ด master์— ์žˆ๋‹ค๊ณ  ํ•˜์ž. CS๊ฐ€ ๋“ค์–ด์˜ค์ง€ ์•Š์€ ์ƒํƒœ์ด๋‹ˆ, ์—…๋ฌด ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด issue๋ฅผ ํ•˜๋‚˜ ๋“ค๊ณ  ์™”๋‹ค.

master๋ธŒ๋žœ์น˜์˜ ๊ฐ€์žฅ ์ตœ์‹  ์ปค๋ฐ‹์„ ๊ธฐ์ค€์œผ๋กœ branching ํ•œ ํ›„, ์ž‘์—…์„ ์ด์–ด๊ฐ”๋‹ค. C3 commit์ด ์ƒ์„ฑ๋˜์—ˆ๋‹ค.

์˜ฌ ๊ฒƒ์ด ์™”๋‹ค. CS๊ฐ€ ๋“ค์–ด์™”๊ณ  hotfix๊ฐ€ ๋‚˜๊ฐ€์•ผ ํ•œ๋‹ค. master branch๋กœ switchํ•œ ํ›„, hotfix branch๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ์ด๋™ํ•˜์ž. ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ ๋’ค commitํ•˜์—ฌ C4๊ฐ€ ์ƒ๊ฒผ๋‹ค.

์ด์ œ hotfix branch๋ฅผ master์— ๋ฐ˜์˜ํ•ด์•ผ ํ•œ๋‹ค. merge๋ฅผ ํ•˜์—ฌ ๋ฐ˜์˜ํ•ด์ฃผ์ž.

$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
 index.html | 2 ++
 1 file changed, 2 insertions(+)

๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ฒŒ๋˜๋ฉด Fast-forward๋ผ๋Š” ๋ฌธ๊ตฌ๊ฐ€ ์ถœ๋ ฅ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๋‚ด๋ถ€์ ์œผ๋กœ git์€ merge์‹œ branch์˜ base commit์ด ๋ฌด์—‡์ธ์ง€ ํ™•์ธํ•œ๋‹ค. ์ด ๊ฒฝ์šฐ, master์™€ hotfix์˜ ancester๊ฐ€ C2๋กœ ๊ฐ™๊ณ , master์˜ ๊ฐ€์žฅ ์ตœ์‹  ์ปค๋ฐ‹์ด hotfix์˜ ์‹œ์ž‘ ์ปค๋ฐ‹๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ ๊ทธ๋ƒฅ branch pointer๋ฅผ hotfix branch์˜ ์ตœ์‹  ์ปค๋ฐ‹์œผ๋กœ ์ด๋™๋งŒ ํ•˜๋ฉด ๋œ๋‹ค. ์ด๋Ÿฐ ๊ฒƒ์„ fast-forward๋ผ ํ•œ๋‹ค.

์ด์ œ hotfix๋ฅผ ๋งˆ์ณค์œผ๋‹ˆ, hotfix branch๋ฅผ ์ง€์šฐ๊ณ  issue branch๋กœ ๋Œ์•„๊ฐ€ ์ž‘์—…์„ ์ด์–ด๊ฐ€์ž. issue branch์—์„œ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์ธ C5๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค.

์ด์ œ issue branch๋ฅผ master์— ๋ฐ˜์˜ํ•ด ์ค„ ์ฐจ๋ก€์ด๋‹ค. ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ancester commit์„ ์ฐพ๋Š”๋‹ค. ์ด ๊ฒฝ์šฐ, ์ผ๋‹จ master branch์— ์žˆ๋Š” C4๊ฐ€ ๊ฐ€์žฅ ์ตœ์‹  ์ปค๋ฐ‹์œผ๋กœ branch pointer๋ฅผ ๊ทธ๋ƒฅ ์˜ฎ๊ธฐ๋Š” ๊ฒƒ์œผ๋กœ๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์—†๋‹ค. ์ฆ‰, fast-forward๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค. ์ด ๊ฒฝ์šฐ git์€ 3-way merge ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•œ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ๋‹ค๋ฃจ๊ธฐ๋กœ ํ•˜์ž. ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งํ•˜๋ฉด, A branch์˜ ๊ฐ€์žฅ ์ตœ์‹  commit, B branch์˜ ๊ฐ€์žฅ ์ตœ์‹  commit๊ณผ ancester commit ์„ธ๊ฐœ๋ฅผ ๊ฐ€์ง€๊ณ  ํ•ฉ์นœ commit์„ ๋งŒ๋“ค์–ด ๋ฐ˜์˜ํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

์ด๋ ‡๊ฒŒ merge๋ฅผ ๋งˆ์น˜๊ณ  ๋‚˜๋ฉด master์—๋Š” ํ•ฉ์ณ์ง„ commit์ด ๋ฐ˜์˜๋˜๊ณ  ์ƒˆ๋กœ์šด commit C6๊ฐ€ ๋งŒ๋“ค์–ด์ง„๋‹ค. ๋ณดํ†ต Merge ~๋กœ ์‹œ์ž‘ํ•˜๋Š” commit์˜ ์ •์ฒด๊ฐ€ ์ด๋…€์„์ด๋‹ค.

Reference