ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [ git ] Merge, Squash and merge, Rebase and merge ์ฐจ์ด
    git 2021. 12. 11. 23:58
    ๋ฐ˜์‘ํ˜•

    ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด git์—์„œ Merge, Squash and merge, Rebase and merge ์ด๋ ‡๊ฒŒ ์„ธ๊ฐ€์ง€์˜ Merge๋ฅผ ์ง€์›ํ•ด์ฃผ๋Š”๋ฐ ์ƒํ™ฉ์— ๋งž๊ฒŒ Merge ๋ฐฉ์‹์„ ๊ด€๋ฆฌํ•˜๋Š”๊ฒŒ ํžˆ์Šคํ† ๋ฆฌ ์ถ”์ ์— ์šฉ์ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ฐจ์ด์ ์„ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค. 

     

    ์ถœ์ฒ˜ : https://stackoverflow.com/questions/2427238/what-is-the-difference-between-merge-squash-and-rebase

     

    Merge

    Merge๋Š” ์œ„์™€๊ฐ™์ด a, b, c ๋ฅผ refer ํ•˜๋Š” m ์ปค๋ฐ‹ ๋…ธ๋“œ๊ฐ€ ์ƒ์„ฑ๋˜๊ณ  m์€ parent๋กœ Init, c ๋ฅผ ๊ฐ€์ง„๋‹ค.

    ์ปค๋ฐ‹ m์—์„œ๋ถ€ํ„ฐ ๋’ค๋กœ ๋˜๋Œ์•„๊ฐ€๋ฉด์„œ ๋ถ€๋ชจ๋ฅผ ๋ชจ๋‘ ์ฐพ์•„ ๋ธŒ๋ Œ์น˜๋ฅผ ๊ตฌ์„ฑํ•˜๊ณ , ์ปค๋ฐ‹ m์€ ๋ถ€๋ชจ๋กœ c, Init์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, c๋Š” b, b๋Š” a, a๋Š” Init์„ ๋‹ค์‹œ ๋ถ€๋ชจ๋กœ ๊ฐ€์ง€๊ฒŒ ๋œ๋‹ค.

    ์ด ํ˜•์ƒ์„ ๋ชจ๋‘ backtrace ํ•˜์—ฌ, Init -> a -> b -> c -> m์ด๋ผ๋Š” ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ๊ตฌ์กฐ๊ฐ€ ๋ชจ๋‘ ํžˆ์Šคํ† ๋ฆฌ์— ๋‚จ๋Š”๋‹ค.


    Squash and Merge

     

     

    a, b, c ๋ฅผ ํ•ฉ์ณ์„œ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์œผ๋กœ ๋งŒ๋“ค๊ณ , ๋จธ์ง€ ๋Œ€์ƒ ๋ธŒ๋ Œ์น˜์— ์ถ”๊ฐ€, 'a,b,c' ์ปค๋ฐ‹์€ parent๋ฅผ Init ํ•˜๋‚˜๋งŒ ๊ฐ€์ง„๋‹ค.

     

    ์ปค๋ฐ‹ 'a,b,c' ๋Š” Init๋งŒ์„ ๋ถ€๋ชจ๋กœ ๊ฐ€์ง„ ๋‹จ์ผ ์ปค๋ฐ‹์œผ๋กœ

    ์ž‘์—…ํ–ˆ๋˜ ๋ธŒ๋ Œ์น˜์˜ a, b, c ์ปค๋ฐ‹๋“ค์€ ๋จธ์ง€ ํ›„์˜ ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜ ์ปค๋ฐ‹ Init, 'a,b,c' ์™€ ์•„๋ฌด๋Ÿฐ ์—ฐ๊ด€์„ ๊ฐ€์ง€์ง€ ์•Š๋Š”๋‹ค.

     


    Rebase and Merge

     

    a, b, c ๋ฅผ ์‹ฌ๋ฆฌ์Šคํ•˜๊ฒŒ ๋จธ์ง€ ๋Œ€์ƒ ๋ธŒ๋ Œ์น˜๋กœ ์ถ”๊ฐ€, ๊ฐ ์ปค๋ฐ‹๋“ค์€ ๋ชจ๋‘ parent๋ฅผ ํ•˜๋‚˜์”ฉ๋งŒ ๊ฐ€์ง„๋‹ค.

     

    ์ปค๋ฐ‹ a, b, c ์˜ ๊ด€๊ณ„๋ฅผ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•œ ์ฑ„, ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜์— ๊ทธ๋Œ€๋กœ ์ถ”๊ฐ€ํ•œ๋‹ค.

    ์ปค๋ฐ‹ a๋Š” ๋ถ€๋ชจ๋กœ ์ปค๋ฐ‹ e๋ฅผ ๊ฐ€์ง€๋ฉฐ, Rebase and Merge ์ž‘์—… ํ›„์—๋Š” ์ž‘์—…ํ–ˆ๋˜ ๋ธŒ๋ Œ์น˜์˜ a, b, c ์ปค๋ฐ‹๋“ค์€ ๋จธ์ง€ ํ›„์˜ ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜์˜ Init, d, e, a, b, c ์ปค๋ฐ‹๋“ค๊ณผ ์—ฐ๊ด€ ๊ด€๊ณ„๋ฅผ ๊ฐ€์ง€์ง€ ์•Š๋Š”๋‹ค.

     


     

    ์–ด๋–ค ๋•Œ์— ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ์ข‹์€๊ฐ€ ?

    • develop - feature ๋ธŒ๋ Œ์น˜๊ฐ„ ๋จธ์ง€ : Squash and Merge๊ฐ€ ์œ ์šฉํ•˜๋‹ค. feature์˜ ๋ณต์žกํ•˜๊ณ  ์ง€์ €๋ถ„ํ•œ ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ๋ชจ๋‘ ๋ฌถ์–ด ์™„์ „ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์œผ๋กœ develop ๋ธŒ๋ Œ์น˜์— ์ถ”๊ฐ€ํ•˜์—ฌ, develop ๋ธŒ๋ Œ์น˜์—์„œ ๋…์ž์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ๋จธ์ง€ ํ›„์— feature ๋ธŒ๋ Œ์น˜๋ฅผ ์‚ญ์ œํ•ด๋ฒ„๋ฆฌ๋Š” ์ ์„ ๋– ์˜ฌ๋ ค ๋ณด๋ฉด, feature ๋ธŒ๋ Œ์น˜์˜ ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ๋ชจ๋‘ develop ๋ธŒ๋ Œ์น˜์— ์ง์ ‘ ์—ฐ๊ด€ ์ง€์–ด ๋‚จ๊ธธ ํ•„์š”๊ฐ€ ์—†๋‹ค.
    • master - develop ๋ธŒ๋ Œ์น˜๊ฐ„ ๋จธ์ง€ : Rebase and Merge๊ฐ€ ์œ ์šฉํ•˜๋‹ค. develop์˜ ๋‚ด์šฉ์„ master์— ์ถ”๊ฐ€ํ•  ๋•Œ์—๋Š” ๋ณ„๋„์˜ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์„ ์ƒ์„ฑํ•  ์ด์œ ๊ฐ€ ์—†๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
    • hotfix - develop, hotfix - master ๋ธŒ๋ Œ์น˜๊ฐ„ ๋จธ์ง€ : Merge ๋˜๋Š” Squash and Merge ๋ชจ๋‘ ์œ ์šฉํ•˜๋‹ค. ๋•Œ์— ๋”ฐ๋ผ ๊ณจ๋ผ ์‚ฌ์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค. hotfix ๋ธŒ๋ Œ์น˜ ์ž‘์—…์˜ ๊ฐ ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๊ฐ€ ๋ชจ๋‘ ๋‚จ์•„์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ Merge, ํ•„์š” ์—†๋Š” ๊ฒฝ์šฐ Squash and Merge๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

     

     

     

     

    ์ฐธ๊ณ  ๋ฐ ์ถœ์ฒ˜ : 

    https://evan-moon.github.io/2019/08/30/commit-history-merge-strategy/#%EB%A0%88%EA%B1%B0%EC%8B%9C-%EC%BD%94%EB%93%9C%EB%A5%BC-%EC%88%98%EC%A0%95%ED%95%B4%EC%95%BC%ED%95%A0-%EB%95%8C

     

    ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๋ฅผ ์ด์˜๊ฒŒ ๋‹จ์žฅํ•˜์ž

    ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Git์˜ ๋จธ์ง€ ์ „๋žต ์ค‘ ๋Œ€ํ‘œ์ ์ธ 3๊ฐ€์ง€์ธ , , ์˜ ์ฐจ์ด์— ๋Œ€ํ•ด์„œ ํ•œ๋ฒˆ ์ด์•ผ๊ธฐํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ์ด 3๊ฐ€์ง€ ๋จธ์ง€ ์ „๋žต ๋ชจ๋‘ ๋ธŒ๋žœ์น˜๋ฅผ ๋จธ์ง€ํ•œ๋‹ค๋Š” ๋ชฉ์ ์€ ๊ฐ™์ง€๋งŒ, ์–ด๋–ค ๋ฐฉ์‹์„ ์„ ํƒํ•˜๋ƒ์—

    evan-moon.github.io

     

    https://meetup.toast.com/posts/122

     

    GitHub์˜ Merge, Squash and Merge, Rebase and Merge ์ •ํ™•ํžˆ ์ดํ•ดํ•˜๊ธฐ : NHN Cloud Meetup

    GitHub์˜ Merge, Squash and Merge, Rebase and Merge ์ •ํ™•ํžˆ ์ดํ•ดํ•˜๊ธฐ

    meetup.toast.com

     

    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€

Designed by Tistory.