Slide 1

Slide 1 text

Merge 1 브랜치와 Merge 의 기초 COPYRIGHT 2022. 김무훈

Slide 2

Slide 2 text

브랜칭 시나리오 2 master 브랜치에 커밋을 몇 번 했다고 가정

Slide 3

Slide 3 text

브랜칭 시나리오 2 master 브랜치에 커밋을 몇 번 했다고 가정 브랜칭 시나리오 — 새 이슈 체크아웃

Slide 4

Slide 4 text

브랜칭 시나리오 2 master 브랜치에 커밋을 몇 번 했다고 가정 브랜칭 시나리오 — 새 이슈 체크아웃 브랜칭 시나리오 — 새 이슈 작업

Slide 5

Slide 5 text

브랜칭 시나리오 3 고쳐야 하는 작업이 갑자기 생기면? 아직 작업 중인 53번 이슈와 섞이는 것을 피하기 위해 핫픽스 브랜치를 만들어서 커밋 C4

Slide 6

Slide 6 text

브랜칭 시나리오 : fast forward merge 4 운영 환경에 적용하려면 hotfix 브랜치를 master 브랜치에 합쳐야 한다.

Slide 7

Slide 7 text

브랜칭 시나리오 : fast forward merge 4 운영 환경에 적용하려면 hotfix 브랜치를 master 브랜치에 합쳐야 한다. $ git checkout master $ git merge hotfix Updating f42c576..3a0874c Fast-forward index.html | 2 ++ 1 file changed, 2 insertions(+)

Slide 8

Slide 8 text

브랜칭 시나리오 : fast forward merge 4 운영 환경에 적용하려면 hotfix 브랜치를 master 브랜치에 합쳐야 한다. $ git checkout master $ git merge hotfix Updating f42c576..3a0874c Fast-forward index.html | 2 ++ 1 file changed, 2 insertions(+) "ಯ׼ ಯ׼ جਸ ؍૑੗ 🎶 https://t.co/giaAVuotHx" / ౟ਤఠ Pull request 2583: Updated README.md - Repos "[VSF %FWPQT ৬ (JU)VC ࢚ਵ۽ח ޷૑ਗ

Slide 9

Slide 9 text

Merge iss53 -> master 5 Fast-foward X

Slide 10

Slide 10 text

Merge iss53 -> master 5

Slide 11

Slide 11 text

Merge iss53 -> master = 3 way Merge 6 п ࠳ے஖о оܻఃח ழ޿ ف ѐ৬ ҕా ઑ࢚ ೞաܳ ࢎਊೞৈ 3-way Mergeܳ ೤פ׮. Common ancestor Snapshot to Merge Into Snapshot to Merge In

Slide 12

Slide 12 text

충돌의 기초 🤯 7 $ git merge iss53 Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. Git — ࠳ے஖৬ Merge ੄ ӝୡ

Slide 13

Slide 13 text

충돌의 기초 🤯 7 $ git merge iss53 Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result. Git — ࠳ے஖৬ Merge ੄ ӝୡ $ git status On branch master You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add ..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a”) vi index.html <<<<<<< HEAD:index.html =======
please contact us at [email protected]
>>>>>>> iss53:index.html

Slide 14

Slide 14 text

Ours, Theirs 소개 8 Git — Ҋә Merge #! /usr/bin/env ruby def hello <<<<<<< ours puts 'hola world' ======= puts 'hello mundo' >>>>>>> theirs end hello() • ours current change : 현재 브랜치의 작업 내역 • Theirs incoming change : 병합 할 파일을 가져온 쪽 ⚠ Rebase 에서는 ours 가 합쳐질 내역이라 정반대입니다. ߽೤ ழ޿ਸ ೞӝ ੹ী ޖ঺੉ ߄Շ঻ח૑ ഛੋೞ۰ݶ git di ff ۽ ঌ ࣻ ੓णפ׮. • git diff ——our: 병합 후의 결과를 병합 전의 내용과 비교 • git diff ——theirs: 병합 할 파일을 가져온 쪽과 비교

Slide 15

Slide 15 text

Ours, Theirs 소개 diff3 base 9 Git — Ҋә Merge git checkout --conflict=diff3 hello.rb #! /usr/bin/env ruby def hello <<<<<<< ours puts 'hola world' ||||||| base puts 'hello world' ======= puts 'hello mundo' >>>>>>> theirs end hello() git checkout conflict: 충돌 난 부분을 수정 중에 원래대로 되 돌리고 다시 고쳐볼려고 할때 사용 • conflict diff3 : base 버전의 내용까지 제공한다. • base: 공통 조상 커밋의 내용 항상 쓰고 싶다면 git config ——global merge.conflictstyle diff3 를 터미널에 입력하세요!

Slide 16

Slide 16 text

Our/Their 일괄 선택으로 자동 병합하기 10 Git — Ҋә Merge • 충돌이 나기 전에 두 브랜치 중 한쪽을 선택하라고 알려줄 수 있다. • merge 명령에 - Xours 나 Xtheirs 옵션을 추가하면 된다. • git merge - Xours branch name • 이래도 충돌이 날 수도 있는데 어느 한쪽을 그대로 가져오고 싶을 때 • —s ours branch name

Slide 17

Slide 17 text

zdiff3 : Git 2.35 에 추가된 새 conflict diff 모드 11 Git — Ҋә Merge git config ——global merge.conflictstyle zdiff3 이 모드는 충돌의 시작이나 끝에서 공통 라인을 충돌 영역 외부로 열심히 이동하여 해결해야 하는 충돌을 조금 더 작게 만듭니다.

Slide 18

Slide 18 text

TIP : 아직 커밋하지 않은 작업을 보관하려면? 12 아직 커밋하지 않은 작업이 이동할 브랜치의 이력과 충돌한다면 브랜치 이동이 차단이 됩니다. 어딘가에 작업 내역을 보관하고 싶다면 Stash 를 사용하면 된다. • git stash add/push: 스택에 집어넣기, git stash pop: 스택에 빼내기 • git stash apply: 스택 맨위 안빼고 가져오기 error: Your local changes to the following files would be overwritten by checkout: file A file B Please commit your changes or stash them before you switch branches. Aborting Git - Stashingҗ Cleaning

Slide 19

Slide 19 text

Git stash Clean 13 • git stash push ——keep—index: unstaging area 만 추가하기 • git stash push ——staged staging area 만 추가하기 • git stash ——patch: 대화형 수정 • git stash branch name : name 이름의 stash를 적용한 apply 브랜치를 만듬 • git clean: 추적 중이지 않은 파일을 제거 Git - Stashingҗ Cleaning

Slide 20

Slide 20 text

Git stash Clean 13 • git stash push ——keep—index: unstaging area 만 추가하기 • git stash push ——staged staging area 만 추가하기 • git stash ——patch: 대화형 수정 • git stash branch name : name 이름의 stash를 적용한 apply 브랜치를 만듬 • git clean: 추적 중이지 않은 파일을 제거 Git - Stashingҗ Cleaning

Slide 21

Slide 21 text

끝 14 COPYRIGHT 2022 김무훈