Skip to content

Git Flow

๋‚จ์ •ํ˜ธ edited this page Nov 15, 2019 · 12 revisions

Work Flow์˜ ์ข…๋ฅ˜

๋Œ€ํ‘œ์ ์œผ๋กœ Git-Flow, GitHub flow, GitLab flow ๊ฐ€ ์žˆ๋‹ค.

๋น„๊ต

Git-flow

GitHub flow

GitLab flow

Git flow์—์„œ ๋ธŒ๋žœ์น˜์˜ ์ข…๋ฅ˜, ๋ธŒ๋žœ์น˜์˜ ์—ญํ• , ๋ธŒ๋žœ์น˜ ์‚ฌ์šฉ๋ฒ• ์ •๋ฆฌ

  • ๋ฉ”์ธ ๋ธŒ๋žœ์น˜

    ๋ฉ”์ธ ๋ธŒ๋žœ์น˜์—๋Š” ๋งˆ์Šคํ„ฐ ๋ธŒ๋žœ์น˜์™€ ๋””๋ฒจ๋กญ ๋ธŒ๋ฆฐ์น˜ ๋‘ ๊ฐœ๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ๋ฉ”์ธ ๋ธŒ๋žœ์น˜๋Š” ํ”„๋กœ์ ํŠธ ๊ธฐ๊ฐ„๋™์•ˆ ์‚ฌ๋ผ์ง€์ง€ ์•Š๊ณ  ๊ณ„์† ์กด์žฌํ•˜๋Š” ๋ธŒ๋žœ์น˜์ž…๋‹ˆ๋‹ค.

    ๋งˆ์Šคํ„ฐ์˜ ํ—ค๋“œ๋Š” ์„œ๋น„์Šค๋˜๊ณ ์žˆ๋Š” ์ƒํƒœ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋””๋ฒจ๋กญ ๋ธŒ๋žœ์น˜์˜ ํ—ค๋“œ๋Š” ๋‹ค์Œ ๋ฆด๋ฆฌ์ฆˆ๋ฅผ ์œ„ํ•ด์„œ ๋งˆ์ง€๋ง‰์œผ๋กœ ์ „๋‹ฌ๋œ ๊ฐœ๋ฐœ ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋””๋ฒจ๋กญ ๋ธŒ๋žœ์น˜์—์žˆ๋Š” ์†Œ์Šค์ฝ”๋“œ๊ฐ€ ์•ˆ์ •๋œ ์ƒํƒœ์ด๊ณ  ๋ฆด๋ฆฌ์ฆˆํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด ๋ชจ๋“  ๋ณ€๊ฒฝ์‚ฌํ•ญ์€ ๋งˆ์Šคํ„ฐ ๋ธŒ๋žœ์น˜๋กœ ๋จธ์ง€๋˜๊ณ  ๋ฆด๋ฆฌ์ฆˆ ๋„˜๋ฒ„๊ฐ€ ํƒœ๊ทธ๋˜์–ด์•ผํ•ฉ๋‹ˆ๋‹ค. ๊ตฌ์ฒด์ ์ธ ์‚ฌํ•ญ์€ ๋’ค์—์„œ ์กฐ๊ธˆ ๋” ์•Œ์•„๋ด…์‹œ๋‹ค.

  • ์„œํฌํŒ… ๋ธŒ๋žœ์น˜

    ๋ฉ”์ธ ๋ธŒ๋žœ์น˜๋“ค์€ ํŒ€ ๋ฉค๋ฒ„๋“ค์ด ํ•จ๊ป˜ ๊ฐœ๋ฐœํ•˜๊ณ , ์ƒํ’ˆ ๋ฆด๋ฆฌ์ฆˆ๋ฅผ ์ค€๋น„ํ•˜๊ณ , ์ƒํ’ˆ์˜ ๋ฌธ์ œ๋ฅผ ์‹ ์†ํ•˜๊ฒŒ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์–‘ํ•œ ์„œํฌํŒ… ๋ธŒ๋žœ์น˜๋“ค์„ ํ™œ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ์„œํฌํŒ… ๋ธŒ๋žœ์น˜๋“ค์€ ํ•ญ์ƒ ์กด์žฌํ•˜์ง€ ์•Š๊ณ  ํ•„์š”์— ๋”ฐ๋ผ ์ƒ๊ฒผ๋‹ค ์‚ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ์“ธ ์„œํฌํŒ… ๋ธŒ๋žœ์น˜๋“ค์—๋Š” ํ”ผ์ณ ๋ธŒ๋žœ์น˜, ๋ฆด๋ฆฌ์ฆˆ ๋ธŒ๋žœ์น˜, ํ•ซํ”ฝ์Šค ๋ธŒ๋žœ์น˜๊ฐ€ ์žˆ๋‹ค. ๊ฐ๊ฐ์˜ ๋ธŒ๋žœ์น˜๋“ค์€ ๋ชฉ์ ์ด ๋šœ๋ ทํ•˜๊ณ , ์–ด๋Š ๋ธŒ๋žœ์น˜์—์„œ ๋ถ„๋ฆฌ๋˜๊ณ  ์–ด๋Š ๋ธŒ๋žœ์น˜์— ๋จธ์ง€๋˜์–ด์•ผํ•˜๋Š”์ง€ ์—„๊ฒฉํ•œ ๋ฃฐ์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ธŒ๋žœ์น˜๋“ค์ด ๊ธฐ์ˆ ์  ๊ด€์ ์—์„œ ํŠน๋ณ„ํ•œ ๊ฒƒ์€ ์ ˆ๋Œ€ ์•„๋‹™๋‹ˆ๋‹ค. ๊ทธ์ € ์–ด๋–ป๊ฒŒ ์“ฐ์ด๋ƒ์— ๋”ฐ๋ผ ๋ถ„๋ฅ˜๋ฉ๋‹ˆ๋‹ค.

    • ํ”ผ์ณ ๋ธŒ๋žœ์น˜

      ์–ด๋””์„œ ๋ถ„๋ฆฌ๋˜๋Š”๊ฐ€? ๋””๋ฒจ๋กญ ๋ธŒ๋žœ์น˜ ์–ด๋””๋กœ ๋จธ์ง€๋˜๋Š”๊ฐ€? ๋””๋ฒจ๋กญ ๋ธŒ๋žœ์น˜ ๋„ค์ด๋ฐ ์ปจ๋ฒค์…˜? master, develop, release-*, hotfix-*๋ฅผ ์ œ์™ธํ•œ ๋ชจ๋‘

      ํ”ผ์ณ ๋ธŒ๋žœ์น˜(๊ฐ„ํ˜น ํ† ํ”ฝ ๋ธŒ๋žœ์น˜๋ผ๊ณ ๋„ ๋ถˆ๋ฆผ)๋Š” ์ถ”ํ›„์— ์ƒˆ๋กœ์šด ๋ฆด๋ฆฌ์ฆˆ์— ๋ฐ˜์˜๋  ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ์„ ์‹œ์ž‘ํ•  ๋•Œ ์ด ๋ธŒ๋žœ์น˜๊ฐ€ ์–ธ์ œ ํ†ตํ•ฉ๋ ์ง€๋Š” ์•Œ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๋ฏธ๋ž˜์— ์ถœ์‹œ ๋  ๋•Œ ๋˜๋Š” ๊ธฐ๋Šฅ์ด ๋ฒ„๋ ค์งˆ ๋•Œ ๋จธ์ง€๋˜๊ฑฐ๋‚˜ ๋ธŒ๋žœ์น˜๊ฐ€ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค. ํ”ผ์ณ ๋ธŒ๋žœ์น˜๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ origin์—๋Š” ์—†๊ณ  ๊ฐœ๋ฐœํ•˜๋Š” ๋กœ์ปฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์—๋งŒ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

      • ํ”ผ์ณ ๋ธŒ๋žœ์น˜ ๋งŒ๋“œ๋Š” ๋ฒ•

        $ git checkout -b myfeature develop
        ์ƒˆ๋กœ์šด ๋ธŒ๋žœ์น˜ 'myfeature'๋กœ ์ „ํ™˜๋ฉ๋‹ˆ๋‹ค.
        
      • ํ”ผ์ณ ๋ธŒ๋žœ์น˜ ํ†ตํ•ฉํ•˜๋Š” ๋ฒ•

        ๊ฐœ๋ฐœ์ด ๋๋‚œ ๊ธฐ๋Šฅ์€ ๋‹ค์Œ ๋ฆด๋ฆฌ์ฆˆ๋ฅผ ์œ„ํ•ด์„œ ๋””๋ฒจ๋กญ ๋ธŒ๋žœ์น˜์— ๋จธ์ง€๋˜์–ด์•ผํ•ฉ๋‹ˆ๋‹ค.

        $ git checkout develop
        'develop' ๋ธŒ๋žœ์น˜๋กœ ์ „ํ™˜๋ฉ๋‹ˆ๋‹ค.
        $ git merge --no-ff myfeature
        Updating ea1b82a..05e9557
        (๋กœ๊ทธ ์š”์•ฝ)
        $ git branch -d myfeature
        'myfeature' ๋ธŒ๋žœ์น˜ ์‚ญ์ œ
        $ git push origin develop
        

        --no-ff ํ”Œ๋ž˜๊ทธ๋ฅผ ์“ฐ๋Š” ์ด์œ ๋Š” ํŒจ์ŠคํŠธ ํฌ์›Œ๋“œ๋กœ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋”๋ผ๋„ ๋จธ์ง€ํ•  ๋•Œ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹ ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•จ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ธŒ๋žœ์น˜๊ฐ€ ์กด์žฌํ–ˆ์—ˆ๋‹ค๋Š” ์‚ฌ์‹ค์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์•Œ ์ˆ˜ ์žˆ๊ณ , ์ถ”๊ฐ€๋œ ํ”ผ์ณ์˜ ์ปค๋ฐ‹๋“ค์„ ๋ชจ์•„๋‘˜ ์ˆ˜ ์žˆ๋‹ค. ๋น„๊ต๊ทธ๋ฆผ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

        contrast-noff-ff

        ๊ทธ๋ฆผ ์ค‘ ํ›„์ž์˜ ๊ฒฝ์šฐ ๊นƒ ํžˆ์Šคํ† ๋ฆฌ์—์„œ ์–ด๋–ค ์ปค๋ฐ‹ ๊ฐ์ฒด๊ฐ€ ํ”ผ์ณ๋ฅผ ๊ตฌํ˜„ํ–ˆ๋Š”์ง€ ๋ณผ ์ˆ˜ ์—†๋‹ค. - ์ „์ž์˜ ๊ฒฝ์šฐ ์‰ฝ๊ฒŒ ์•Œ์•„๋ณผ ์ˆ˜ ์žˆ๋Š” ๋ฐ˜๋ฉด์— ํ›„์ž๋Š” ๊ธฐ๋Šฅ์„ ๋˜๋Œ๋ฆฌ๊ณ ์ž ํ–ˆ์„ ๋•Œ ๋ชจ๋“  ๋กœ๊ทธ ๋ฉ”์„ธ์ง€๋ฅผ ์ฝ์–ด์•ผํ•œ๋‹ค. ์ „์ž์˜ ๊ฒฝ์šฐ ์“ธ๋ฐ์—†๋Š” ์ปค๋ฐ‹ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜๊ฒ ์ง€๋งŒ ๊ทธ๋กœ์ธํ•ด ์–ป๋Š” ๊ฒƒ์ด ๋” ํฌ๋‹ค.

Flow

  1. ๋ธŒ๋žœ์น˜ ์ตœ์‹ ํ™”๋ฅผ ์œ„ํ•˜์—ฌ develop ๋ธŒ๋žœ์น˜๋ฅผ ์ตœ์‹ ์˜ ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.
[develop] git pull --rebase upstream develop
# upstream repo์— ์žˆ๋Š” develop ๋ธŒ๋žœ์น˜๋ฅผ pull ํ•œ๋‹ค.
# develop์— ์ง์ ‘ ์ปค๋ฐ‹์„ ํ•œ ๊ฒฝ์šฐ๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” --rebase ๋ช…๋ น์–ด๋ฅผ ๋นผ๋„ ๋ฌด๋ฐฉํ•˜๋‹ค.
  1. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
[์•„๋ฌด ๋ธŒ๋žœ์น˜] git checkout -b feat-make_new_feature develop
# develop ๋ธŒ๋žœ์น˜์—์„œ feat-make_new_feature ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ฒดํฌ ์•„์›ƒํ•˜๋Š” ๋ช…๋ น์–ด.
  1. ์ž‘์—…์„ ํ•œ๋‹ค.
  2. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ ์ตœ์‹ ํ™” ์‹œํ‚จ๋‹ค.
[feat-make_new_feature] git pull --rebase upstream develop
# ๋‚ด๊ฐ€ PR ์„ ๋‚ ๋ฆฌ๊ธฐ ์ „์—, upstream์˜ develop์ด ์—…๋ฐ์ดํŠธ ๋˜์—ˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๊ธฐ ๋•Œ๋ฌธ์—, rebase๋ฅผ ๋จผ์ € ํ•ด์ค€๋‹ค.
  1. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ origin ์— push ํ•œ๋‹ค.
[feat-make_new_feature] git push origin feat-make_new_feature
  1. github ์ƒ์—์„œ PR์„ ๋ณด๋‚ธ๋‹ค.
[base repository:***][base:develop] <= [head repository:****][base:feat-make_new_feature]

์ด๊ฒƒ์ด ์œ„ ์„ธ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ข…ํ•ฉ์ ์œผ๋กœ ์ •๋ฆฌํ•œ ๊ฒƒ์ด๋‹ค.

์šฐ๋ฆฌ ํŒ€์€ ์–ด๋–ป๊ฒŒ ํ–ˆ๋‚˜

ํ•„์ž๊ฐ€ ์ฐธ์—ฌํ•œ ํŒ€์€ ์—ฌ๋Ÿฌ ์‹œํ–‰ ์ฐฉ์˜ค ๋์— ์œ„์˜ ๊ณผ์ •์„ ์•ฝ๊ฐ„ ๋ณ€ํ˜• ์‹œํ‚ค๊ธฐ๋กœ ํ•˜์˜€๋‹ค. ์œ„์˜ ๋ฐฉ์‹์„ ๊ทธ๋Œ€๋กœ ์ง„ํ–‰ํ•˜๋ฉด, feature๋ฅผ ๋งŒ๋“œ๋Š” ์ž‘์—…์„ ํ•  ๋•Œ์—, ๋‚ด๊ฐ€ ๊ณผ๊ฑฐ์— ๋งŒ๋“ค์—ˆ๋˜ ์ปดํฌ๋„ŒํŠธ๊ฐ€ merge ๋˜์ง€ ์•Š์œผ๋ฉด, ๋‹ค์Œ ์ž‘์—…์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜๊ฐ€ ์—†๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ž‘์—… ์†๋„์— ์œ ์˜๋ฏธํ•œ ๋ถ€์ •์  ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค๋Š” ๊ฒฐ๋ก ์— ์ด๋ฅด๋Ÿฌ ๋ฐฉ์‹์„ ๋ณ€๊ฒฝํ•˜์˜€๋‹ค.

Flow - ๋ณ€ํ˜•

  1. ๋ธŒ๋žœ์น˜ ์ตœ์‹ ํ™”๋ฅผ ์œ„ํ•˜์—ฌ develop ๋ธŒ๋žœ์น˜๋ฅผ ์ตœ์‹ ์˜ ์ƒํƒœ๋กœ ๋งŒ๋“ ๋‹ค.
[develop] git pull --rebase upstream develop
# upstream repo์— ์žˆ๋Š” develop ๋ธŒ๋žœ์น˜๋ฅผ pull ํ•œ๋‹ค.
# develop์— ์ง์ ‘ ์ปค๋ฐ‹์„ ํ•œ ๊ฒฝ์šฐ๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” --rebase ๋ช…๋ น์–ด๋ฅผ ๋นผ๋„ ๋ฌด๋ฐฉํ•˜๋‹ค.
  1. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
[์•„๋ฌด ๋ธŒ๋žœ์น˜] git checkout -b feat-make_new_feature develop
# develop ๋ธŒ๋žœ์น˜์—์„œ feat-make_new_feature ๋ธŒ๋žœ์น˜๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ฒดํฌ ์•„์›ƒํ•˜๋Š” ๋ช…๋ น์–ด.
  1. ์ž‘์—…์„ ํ•œ๋‹ค.
  2. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ ์ตœ์‹ ํ™” ์‹œํ‚จ๋‹ค.
[feat-make_new_feature] git pull --rebase upstream develop
# ๋‚ด๊ฐ€ PR ์„ ๋‚ ๋ฆฌ๊ธฐ ์ „์—, upstream์˜ develop์ด ์—…๋ฐ์ดํŠธ ๋˜์—ˆ์„ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๊ธฐ ๋•Œ๋ฌธ์—, rebase๋ฅผ ๋จผ์ € ํ•ด์ค€๋‹ค.
  1. ์ž‘์—… ๋ธŒ๋žœ์น˜๋ฅผ develop ๋ธŒ๋žœ์น˜์— merge ํ•œ๋‹ค.
[feat-make_new_feature] git checkout develop
[develop] git merge feat-make_new_feature
[develop] git branch -d feat-make_new_feature
  1. develop ๋ธŒ๋žœ์น˜๋ฅผ origin ์— push ํ•œ๋‹ค.
[develop] git push origin develop
  1. github ์ƒ์—์„œ PR์„ ๋ณด๋‚ธ๋‹ค.
[base repository:***][base:develop] <= [head repository:****][base:develop]
Clone this wiki locally