GitNotes.38-1.md
본 문서는 Git Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.

Section 38.1: Merge conflict 수동 해결하기

git merge 를 수행하다 보면 git 이 "merge conflict" 에러를 발생시키는 경우를 만날 수 있다. 해당 에러는 어떤 파일들에서 conflict 이 발생하였는지를 알려줄 것이며, 사용자는 해당 정보를 토대로 conflict 을 해결하여야 한다.

해결 작업 중 아무때나 git status 명령어를 통해 어떤 파일들이 아직 작업이 필요한 상태로 남아있는지에 대한 유용한 정보를 얻을 수 있다.

On branch master You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")

Git 은 해당 파일들에 표시자를 남겨놓음으로써 conflict 이 어느 부분에서 발생하였는지를 알려준다:

<<<<<<<<< HEAD: index.html #indicates the state of your current branch <div id="footer">contact : email@somedomain.com</div> ========= #indicates break between conflicts <div id="footer"> please contact us at email@somedomain.com </div> >>>>>>>>> iss2: index.html #indicates the state of the other branch (iss2)

conflict 을 해결하기 위해서는, <<<<<< 와 >>>>>>> 표시자 사이의 내용을 적절히 편집한 후, 상태 표시 라인 (<<<<<<<, >>>>>>>, 그리고 ======== 표시 라인) 을 삭제하도록 한다. 그런 다음, git add index.html 명령을 통해 해당 파일의 conflict 이 해결되었음을 표시해 놓고 모든 수정이 완료되었을 때 최종적으로 git commit 을 수행하여 merge 작업을 끝마치면 된다.

[출처] https://books.goalkicker.com/GitBook/ (CC BY-SA)

반응형

+ Recent posts