-
Ch12. Merge ConflictsRay Wenderlich/Mastering Git 2021. 8. 23. 00:58
What is a merge conflict?
Git은 Merge를 할 때, Longest Common Subsequence(LCS)를 사용한다.
먼저 내가 수정한 파일과 Common ancestor의 변경사항을 비교하여 공통부분을 찾는다.
그 다음, Merge할 브랜치의 파일을 Common ancestor와 비교하여 공통부분을 찾는다.
Git은 이 방식으로 LCS를 찾아낸 뒤 비교해본다.
"What has changed between the common ancestor and this new file?"
그 다음,
"Now, of those changes in each pair of files, are there any sets of lines that have changed differently between each pair?"
만약 존재한다면 Merge Conflict가 발생한다.
A better way to view merge conflicts
git config merge.conflictstyle diff3 # default value is merge. git config merge.conflictstyle merge
diff3 옵션을 선택하면 conflict가 발생했을 때 ours, theirs 뿐만 아니라 common ancestor의 상태도 보여준다.
git status -sb ## zIntegration...origin/zIntegration A css/main.css UU index.html
A와 UU는 무슨 의미일까?
You have one file added (A) on your local branch; this is css/main.css that Yasmin must have added in her work. But it’s not in conflict with your work.
On the other hand, you have not one, but two revisions of a file that are unmerged (U) in your branch. This is the original index.html from the zIntegration branch, and the index.html from your yUI branch.
'Ray Wenderlich > Mastering Git' 카테고리의 다른 글
Ch13. Stashes (0) 2021.09.21 Ch11. How Does Git Actually Work? (0) 2021.08.23 Ch10. Merging (0) 2021.08.21 Ch9. Creating a Repository (0) 2021.08.21 Ch8. Syncing With a Remote (0) 2021.08.21