Merge conflict 는 branch를 합치는 과정에서
Git이 어느 내용을 남겨야 할지 자동으로 결정하지 못할 때 발생하는 충돌이다.
보통 아래 상황에서 발생한다.
git mergegit pullgit pull --rebase- 같은 파일의 같은 부분을 서로 다르게 수정했을 때
git merge feature/login
Auto-merging app.css
CONFLICT (content): Merge conflict in app.css
Automatic merge failed; fix conflicts and then commit the result.git statusOn branch main
You have unmerged paths.
Unmerged paths:
both modified: app.css<<<<<<< HEAD
button color: blue
=======
button color: red
>>>>>>> feature/login
HEAD: 현재 branch 내용- 아래쪽 : 합치려는 branch 내용
이 표시를 보고 직접 원하는 내용으로 수정해야 한다.
button color: blue;
또는 둘 내용을 합쳐서 새로 정리한다.
아래 표시는 전부 없어져야 한다.
<<<<<<<
=======
>>>>>>>
git add .
git commit -m "MERGE: resolve conflict"해결하지 않고 merge 전 상태로 돌아가려면:
git merge --abortgit add .
git rebase --continue취소하려면:
git rebase --abortMerge conflict 는
같은 부분을 서로 다르게 수정해서 Git이 자동 병합을 못 하는 상태이고,
파일을 직접 수정한 뒤 git add 후 다시 진행해야 한다.