Git - Merge and Conflict

Jungminยท2022๋…„ 11์›” 22์ผ
0

Git

๋ชฉ๋ก ๋ณด๊ธฐ
6/6

๐Ÿ“™ Merge : Branch๋ฅผ ๋‹ค์‹œ ๋ณ‘ํ•ฉํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ
๐Ÿ“™ Conflict : merge๊ณผ์ •์—์„œ ์–‘์ชฝ์ด ๊ฐ™์€ ์ฝ”๋“œ ๋ถ€๋ถ„ ๊ณ ์ณค์„ ๋•Œ ์ด ๋ถ€๋ถ„์„ ์•Œ๋ ค์ฃผ๋Š” ๊ฐœ๋…

์‹ค์Šตํ™˜๊ฒฝ ์ƒ์„ฑ

  • merge_project ์ƒ์„ฑ ํ›„ git_ws์— ๋ณต์ œ
  • ํŒŒ์ผ ์ถ”๊ฐ€ ํ›„ ์ €์žฅ
  • branch์ƒ์„ฑ ํ›„ ํŒŒ์ผ ์ˆ˜์ • ( cat >> : ๋‚ด์šฉ ์ˆ˜์ •์ด ์•„๋‹Œ ๋‚ด์šฉ ์ถ”๊ฐ€)

โน Merge Tool ์„ค์ •

โœ” Git Configuration ํŒŒ์ผ ์—ด๊ธฐ

git config --global -e

โœ” Git Merge ์„ค์ • ์ถ”๊ฐ€

โน Merge

--> dev branch (my name is noma. are you?) / main branch (my name is noma.)

โœ” Git Merge (ํ˜„์žฌ ์œ„์น˜ํ•œ branch์— ๋‹ค๋ฅธ branch ๋ณ‘ํ•ฉ)

git merge <branch ๋ช…> : ํ˜„์žฌ branch 'main'์—์„œ dev branch merge (--> are you? ์ถ”๊ฐ€ ํ™•์ธ)

โœ” dev Branch Merge

log ํ™•์ธ : dev ์— modify 1 ์กด์žฌํ•œ๊ฒŒ main branch์—๋„ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธ. (HEAD -> main, dev) : ํ•ด๋‹น commit์ด main, dev์— ์กด์žฌ

โน Conflict

Merge conflict : branch๋ฅผ merge(ํ˜น์€ push/pull)ํ•˜๋Š” ๊ณผ์ •์—์„œ ์ถฉ๋Œ์ด ๋‚  ์ˆ˜ ์žˆ์Œ.

โœ” main branch์—์„œ ํŒŒ์ผ ์ˆ˜์ • (Hello, noma)

โœ” conflict test์œ„ํ•œ branch์ƒ์„ฑ - Hello, noma ์นดํ”ผ (์ด๋™์€ X)

โœ” main branch์—์„œ ํŒŒ์ผ ์ˆ˜์ • (Hello, zero)

โœ” Dev2 Branch์—์„œ ํŒŒ์ผ ์ˆ˜์ • (Hello, base)

โœ” Main branch์—์„œ Dev2 Merge (์–‘์ชฝ์ด ๊ฐ™์€ ํŒŒ์ผ์˜ ๊ฐ™์€ ๋ถ€๋ถ„ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ถฉ๋Œ ๋ฐœ์ƒ)

โœ” MergeTool ์‹คํ–‰ (conflict๋‚œ ํŒŒ์ผ๋“ค์ด ์ฐจ๋ก€๋กœ ์—ด๋ฆผ)

โœ” VS Code์—์„œ conflictํŒŒ์ผ ์ˆ˜์ • (main, dev2 branch์˜ Diff๋ฅผ <<<<, ====, >>>>๋กœ ํ‘œ์‹œ)

โœ” conflict ํ•ด์ œ

git add + git commit

โœ” commit message ์ €์žฅ ํ›„ ์™„๋ฃŒ

โœ” Git Log๋กœ ํ™•์ธ

profile
๋ฐ์ดํ„ฐ๋ถ„์„ ์Šคํ„ฐ๋””๋…ธํŠธ๐Ÿงโœ๏ธ

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