SVN branch, merge, switch

๋ฐ•๊ฑด์šฐยท2022๋…„ 12์›” 30์ผ
1
post-thumbnail

๐Ÿ’ก trunk, branch, merge

trunk ?
์†Œ์Šค์˜ ์ฃผ ๊ฐœ๋ฐœ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๋Š” ํด๋”

branch ?
์†Œ์Šค์˜ ํ˜„์žฌ ๋ฒ„์ „์„ ์œ ์ง€๋ณด์ˆ˜ํ•˜๊ณ , ํ˜„์žฌ ๋ฒ„์ „์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฐจ๊ธฐ ๋ฒ„์ „์„ ๊ฐœ๋ฐœํ•˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉํ•˜๋Š” ํด๋”

merge ?
branch ์†Œ์Šค ๊ฐœ๋ฐœ์ด ์™„๋ฃŒ๊ฐ€ ๋˜๋ฉด trunk๋‚˜ ๋‹ค๋ฅธ branch์™€ ํ•ฉ์น˜๋Š” ์ž‘์—…


branching

Project SVN Checkout

๋จผ์ € ํ”„๋กœ์ ํŠธ ํด๋”๋ฅผ SVN Checkout ๋ฐ›๋Š”๋‹ค.
์šฐ๋ฆฌ๋Š” ๋Œ€๋ถ€๋ถ„ trunk ์œ„์น˜๊นŒ์ง€ Checkout ๋ฐ›์•„ ๋ˆˆ์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์—†์—ˆ์ง€๋งŒ, ํ”„๋กœ์ ํŠธ ํด๋” ํ•˜์œ„์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์„ธ ๊ฐœ์˜ ํด๋”๊ฐ€ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

branch ์ƒ์„ฑ, branching

trunk ํด๋” ๋งˆ์šฐ์Šค ์šฐํด๋ฆญ > TortoiseSVN > Branch/tag To Path ์ž…๋ ฅ ์นธ ์šฐ์ธก์— ... ์„ ํด๋ฆญํ•ด์ค€๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ์ฐฝ์ด ํ•˜๋‚˜ ๋œจ๋Š”๋ฐ, URL ์ž…๋ ฅ ์นธ์— branches ํด๋” ํ•˜์œ„์— ์ž์‹ ์ด ์ƒ์„ฑํ•  branch์˜ ์ด๋ฆ„์„ ์ ๊ณ  OK ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ๋‹ค. Ex) ~/branches/gwpark

๋‹ค์‹œ ๋ฉ”์ธ ์ฐฝ์œผ๋กœ ๋Œ์•„์™€ ๋กœ๊ทธ ๋ฉ”์‹œ์ง€๋ฅผ ์ž‘์„ฑํ•˜๊ณ , ๋ณต์‚ฌํ•  repository revision์„ ๊ฒฐ์ •ํ•œ๋‹ค.

  1. branch ์ƒ์„ฑ ๋กœ๊ทธ ๋‚จ๊ธฐ๋Š” ์šฉ๋„
  2. copyํ•  ์ €์žฅ์†Œ(trunk)์˜ revision ์ง€์ •
    2-1. HEAD revision in the repository - trunk์˜ ์ตœ์ข… revision
    2-2. Specific revision in repository - ์ž…๋ ฅํ•œ revision (Show Log ๋ฒ„ํŠผ์œผ๋กœ revision์ด๋ ฅ ํ™•์ธ ๊ฐ€๋Šฅ)

๊ทธ ๋‹ค์Œ, SVN Update ํ•ด์ฃผ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด trunk ํ•˜์œ„ ํด๋” ๋ฐ ํŒŒ์ผ๋“ค์ด ๋ชจ๋‘ copy ๋˜์–ด ์ƒ์„ฑํ•œ branch ํ•˜์œ„์— ์ถ”๊ฐ€๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

merging

IDE์—์„œ branch ์†Œ์Šค ์ˆ˜์ • ์ž‘์—…์„ ๋งˆ์น˜๊ณ , ์ˆ˜์ • ๋‚ด์šฉ์„ commit ํ•œ๋‹ค.

merge ์ž‘์—… ์ด์ „์—๋Š” ๋ฐ˜๋“œ์‹œ trunk์™€ branch ๋ชจ๋‘ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์—†์ด commit ๋œ ์ƒํƒœ์—ฌ์•ผ ํ•œ๋‹ค.

TortoiseSVN > Merge..

Merge type์„ ์„ ํƒํ•˜๋Š” ๋‹จ๊ณ„๋‹ค. ์ด๋Š” ์•„๋ž˜ ๋‚ด์šฉ์„ ์ฐธ๊ณ ํ•ด์„œ ์„ ํƒํ•˜๋ฉด ๋œ๋‹ค.
๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ Merge two different trees ํƒ€์ž…์œผ๋กœ ์ง€์ •ํ•˜๋ฉด ๋  ๊ฒƒ์ด๋‹ค.

๐Ÿ’ก merge type !!

  • Merge a range of revisions
    branch ์†Œ์Šค๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ํ•ด๋‹น ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋‹ค๋ฅธ branch(ํ˜น์€ trunk)๋กœ ์ด์‹ํ•˜๋Š” ๊ฒฝ์šฐ

    [FROM] branch A์˜ revision 1 [TO] branch A์˜ revision 7 ๋กœ ์žก์•˜๋‹ค๊ณ  ๊ฐ€์ • โ†’ branch A์˜ revision 1~7๊นŒ์ง€์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋‹ค๋ฅธ brunch๋‚˜ trunk์— merge

  • Merge two different trees
    branch์—์„œ ์ˆ˜์ •๋œ ์†Œ์Šค๋ฅผ trunk์— ๋™์ผํ•˜๊ฒŒ ์ ์šฉํ•˜๋Š” ๊ฒฝ์šฐ

    [FROM] trunk์˜ Head revision [TO] branch์˜ Head revision โ†’ trunk์˜ ์ตœ์ข… ๋ฒ„์ „๊ณผ branch์˜ ์ตœ์ข… ๋ฒ„์ „์„ merge

From URL - trunk ํด๋” ์œ„์น˜, To URL - branch ํด๋” ์œ„์น˜๋กœ ์žก๊ณ  mergeํ•˜๊ณ ์ž ํ•˜๋Š” ๊ฐ๊ฐ์˜ revision์„ ์„ ํƒํ•œ๋‹ค.

์•„๋ž˜ ์ฐฝ์€ merge์˜ ์˜ต์…˜์„ ์„ ํƒํ•˜๋Š” ๋‹จ๊ณ„์ธ๋ฐ, ๋ณ„๋„์˜ ์˜ต์…˜ ์„ ํƒ์ด ํ•„์š” ์—†์„ ๊ฒƒ์ด๋ฏ€๋กœ ์•„๋ž˜ Merge ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ด merge๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.

merge ์ž‘์—…์ด ์•„๋ž˜์™€ ๊ฐ™์ด ์™„๋ฃŒ๋˜์—ˆ๋‹ค.
trunk ์†Œ์Šค๋ฅผ ์‚ดํŽด๋ดค์„ ๋•Œ, branch์—์„œ ์ˆ˜์ •ํ–ˆ๋˜ ๋‚ด์šฉ์ด ๋™์ผํ•˜๊ฒŒ ์ ์šฉ๋œ ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค๋ฉด ์„ฑ๊ณต์ ์œผ๋กœ merge๊ฐ€ ์ด๋ฃจ์–ด์ง„ ๊ฒƒ์ด๋‹ค.

์ตœ์ข…์ ์œผ๋กœ, merge๊ฐ€ ์™„๋ฃŒ๋œ trunk ์†Œ์Šค๋ฅผ commitํ•˜์—ฌ SVN ์„œ๋ฒ„์— ๋ฐ˜์˜ํ•ด์ค€๋‹ค.

On IntelliJ

IntelliJ์—์„œ๋„ branching, merging๊ณผ ๊ฐ™์€ ์ž‘์—…๋“ค์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

  1. ํ”„๋กœ์ ํŠธ ์šฐํด๋ฆญ > Subversion > Branch or Tag
    โ€ข Base URL : SVN ์„œ๋ฒ„์—์„œ ๋ธŒ๋žœ์น˜๋ฅผ ์ €์žฅํ•  ๊ฒฝ๋กœ
    โ€ข Name : ๋ธŒ๋žœ์น˜๋ช…

  2. ์ƒ๋‹จ SVN > Update Project์—์„œ branch ํ”„๋กœ์ ํŠธ๋กœ ๋“ค์–ด๊ฐ„๋‹ค.

  3. ์†Œ์Šค ์ˆ˜์ • ํ›„ commitํ•˜๋ฉด SVN ์„œ๋ฒ„์˜ ํ•ด๋‹น branch์—์„œ๋งŒ ์†Œ์Šค๊ฐ€ ๋ณ€๊ฒฝ๋œ๋‹ค.

  4. ๋‹ค์‹œ SVN > Update Project์—์„œ trunk ํ”„๋กœ์ ํŠธ๋กœ ๋“ค์–ด๊ฐ„๋‹ค.

  5. ํ”„๋กœ์ ํŠธ ์šฐํด๋ฆญ > Subversion > Integrate Directory ํด๋ฆญํ•ด์„œ ์ˆ˜์ • ์ž‘์—…ํ•œ branch๋ฅผ trunk๋กœ ๋ณ‘ํ•ฉํ•œ๋‹ค.

  6. trunk ์†Œ์Šค๋ฅผ SVN ์„œ๋ฒ„์— commit ํ•œ๋‹ค.

On Eclipse

Eclipse ์ƒ์—์„œ branch ํ”„๋กœ์ ํŠธ์™€ trunk ํ”„๋กœ์ ํŠธ ๊ฐ„์˜ ์†Œ์Šค ๊ด€๋ฆฌ ๋ฐฉ์‹์—๋Š” ํฌ๊ฒŒ ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ๋กœ branch๋ฅผ ์ƒ์„ฑ๋งŒ ํ•˜๊ณ  trunk ํ”„๋กœ์ ํŠธ์™€ branch ํ”„๋กœ์ ํŠธ๋ฅผ ์„œ๋กœ Switch ์‹œ์ผœ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ด ์žˆ๊ณ , ๋‘ ๋ฒˆ์งธ๋กœ branch ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒˆ๋กœ checkout ๋ฐ›์•„ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์ด ์žˆ๋‹ค.

์ผ๋‹จ branch ์ƒ์„ฑ ๊ณผ์ •์€ ์ด์™€ ๊ด€๊ณ„ ์—†์ด ๋™์ผํ•˜๊ฒŒ ์ง„ํ–‰ํ•œ๋‹ค.

  • branch๋ฅผ ์ƒ์„ฑํ•  ํ”„๋กœ์ ํŠธ ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > Team > Branch

  • ์ƒ์„ฑํ•  branch๋ช…์„ ์ž…๋ ฅํ•˜๊ณ , copy ๋ฐฉ๋ฒ•์„ ์„ ํƒํ•˜์—ฌ ์ƒˆ๋กœ์šด branch๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

  • Use the working copy as it is : ํ•ด๋‹น Local์˜ ํ”„๋กœ์ ํŠธ ์†Œ์Šค๋กœ branch ์ƒ์„ฑ

  • Use the repository version : SVN ๋ฒ„์ „ ์ค‘์— ์„ ํƒํ•ด branch ์ƒ์„ฑ

์—ฌ๊ธฐ์„œ๋ถ€ํ„ฐ ๊ด€๋ฆฌ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ „๊ฐœ ๊ณผ์ •์ด ๋‹ฌ๋ผ์ง„๋‹ค.

Switch

  1. branch๋ฅผ ์ƒ์„ฑํ•  ํ”„๋กœ์ ํŠธ ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > Team > Switch

  2. URL์— ์ƒ์„ฑํ•œ branch ๊ฒฝ๋กœ๋ฅผ ์ฐพ์•„ ์ž…๋ ฅํ•œ๋‹ค.

  1. Switch ์ž‘์—…์ด ์™„๋ฃŒ๋˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด branch ํ”„๋กœ์ ํŠธ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋œ๋‹ค.

  2. branch ํ”„๋กœ์ ํŠธ์—์„œ ํ•„์š”ํ•œ ์ž‘์—…์„ ์ง„ํ–‰ํ•œ๋‹ค.

    branch์˜ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ–ˆ์œผ๋ฉด commitํ•˜์—ฌ branch๋ณ„๋กœ ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ํ•ด์ค˜์•ผ ํ•œ๋‹ค. ๋งŒ์•ฝ commitํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์›์น˜ ์•Š๋Š” ๋‚ด์šฉ์ด trunk ์†Œ์Šค์— ์ ์šฉ๋  ์ˆ˜ ์žˆ๋‹ค. ์ด ์ ์„ ๋ฐ˜๋“œ์‹œ ์œ ์˜ํ•˜์ž.

  3. branch ํ”„๋กœ์ ํŠธ์˜ ์†Œ์Šค ์ˆ˜์ •์ด ์™„๋ฃŒ๋˜์—ˆ๋‹ค๋ฉด, ํ”„๋กœ์ ํŠธ๋ฅผ trunk๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.

  4. ํ”„๋กœ์ ํŠธ ๋งˆ์šฐ์Šค ์˜ค๋ฅธ์ชฝ ํด๋ฆญ > Team > Merge

  5. URL์— mergeํ•˜๊ณ ์ž ํ•˜๋Š” branch์˜ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  OK ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ๋‹ค.

  6. branch์—์„œ ๋ณ€๊ฒฝ๋œ ๋‚ด์—ญ์ด ์•„๋ž˜์™€ ๊ฐ™์ด ํ‘œ์‹œ๋˜๊ณ , ์ˆ˜์ •๋œ ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ํ•ด๋‹น ํŒŒ์ผ์„ ํด๋ฆญํ•˜์—ฌ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

  1. ํ‘œ์‹œ๋œ ๋‚ด์—ญ ์ค‘ merge ์‹œํ‚ค๊ณ  ์‹ถ์€ ๋‚ด์—ญ๋งŒ ๋งˆ์šฐ์Šค ์šฐํด๋ฆญํ•ด Acceptํ•˜๋ฉด ๋ณ‘ํ•ฉ์ด ์™„๋ฃŒ๋œ๋‹ค.

์ถฉ๋Œ์ด ๋ฐœ์ƒํ•œ ํŒŒ์ผ์€ Override and Update ํ•ด์ค˜ ๊ธฐ์กด์˜ trunk ์†Œ์Šค๋ฅผ branch ์†Œ์Šค๋กœ ๋ฎ์–ด ์”Œ์›Œ์ฃผ๊ฑฐ๋‚˜ ์ฝ”๋“œ๋ฅผ ์•Œ๋งž๊ฒŒ ์ˆ˜์ •ํ•˜๊ณ  resolve ์‹œํ‚จ ํ›„ ์ง„ํ–‰ํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋ณ‘ํ•ฉ์ด ์™„๋ฃŒ๋œ๋‹ค.

  1. ์ตœ์ข…์ ์œผ๋กœ trunk์˜ ์†Œ์Šค๋ฅผ commitํ•˜์—ฌ SVN Server์— ๋ฐ˜์˜ํ•œ๋‹ค.

Branch Checkout

SVN Reposiotry๋ฅผ refresh ์‹œํ‚จ ํ›„ ํ™•์ธํ•ด๋ณด๋ฉด branches ํ•˜์œ„์— ์ƒ์„ฑํ•œ branch๊ฐ€ ์ƒ๊ฒจ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

  1. ํ•ด๋‹น branch๋ฅผ Checkout ๋ฐ›๋Š”๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด branch ํ”„๋กœ์ ํŠธ๊ฐ€ Project Explorer ํƒญ์— ๋‚˜ํƒ€๋‚˜๊ณ , ์ €์žฅ ์˜์—ญ์ด
๋‹ค๋ฅธ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

  1. branch ํ”„๋กœ์ ํŠธ์—์„œ ํ•„์š”ํ•œ ์ž‘์—…์„ ์ง„ํ–‰ํ•˜๊ณ  commitํ•œ๋‹ค.

    ์ด ๋•Œ, trunk ํ”„๋กœ์ ํŠธ์™€๋Š” ๋ณ„๊ฐœ๋กœ branch ์˜์—ญ์— commit์ด ๋œ๋‹ค. ํ•˜์ง€๋งŒ ๊ฐ™์€ ํ”„๋กœ์ ํŠธ์ฒ˜๋Ÿผ revision์ด ์ด์–ด์„œ ์˜ฌ๋ผ๊ฐ€๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

  2. ์ดํ›„์— merge ์ž‘์—… ์ „๊ฐœ ๊ณผ์ •์€ Switch ๋ฐฉ์‹๊ณผ ๋™์ผํ•˜๋‹ค. (Switch 6๋ฒˆ๋ถ€ํ„ฐ ์ฐธ๊ณ )

0๊ฐœ์˜ ๋Œ“๊ธ€