Windows/유용한 풀그림

[git] MERGE_HEAD exists 문제 해결하기

채윤아빠 2024. 6. 27. 17:53
728x90
반응형

문제점 및 증상

새로운 브랜치에서 작업하던 것을 상위 브랜치에서 머지한 후, 작업 폴더를 pull 하려는 도중에 다음과 같은 오류를 만나게 되었습니다.

$ git pull
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.


위와 같이 "error: You have not concluded your merge (MERGE_HEAD exists)." 오류가 발생하였을 때 문제 해결 과정을 정리해 둡니다.


해결 과정

우선 다음과 같이 머지를 취소합니다.

$ git merge --abort


이후 pull 을 하면, 아래와 같이 자동으로 수정된 부분들이 머지되는데, 저의 경우 소스 몇몇 부분에서 충돌 (CONFLICT)이 발생하였습니다.

$ git pull
Auto-merging .gitignore
Auto-merging backend_server/src/constants.py
CONFLICT (content): Merge conflict in backend_server/src/constants.py
Automatic merge failed; fix conflicts and then commit the result.


충돌이 발생한 부분을 적절히 수정해 줍니다.

수정이 완료된 후에 commit 및 push하여 브랜치를 정상화하였습니다.