현재 일어나고있는 것은 이전에 병합하려고 시도했지만 병합 충돌을 일으킨 특정 파일 세트가 있다는 것입니다. 이상적으로, 병합 충돌이 발생하면 수동으로 해결하고를 사용하여 변경 사항을 커밋해야합니다 git add file.name && git commit -m "removed merge conflicts". 이제 다른 사용자가 자신의 저장소에서 문제의 파일을 업데이트하고 변경 사항을 공통 업스트림 저장소로 푸시했습니다.
병합이 마지막 커밋과 충돌했을 가능성이 크지 않으므로 파일이 제대로 병합되지 않아 파일의 U( unmerged) 플래그가 발생합니다. 이제는.을 수행 할 때 git pullgit에서 오류가 발생합니다. 파일의 일부 버전이 올바르게 해결되지 않았기 때문입니다.
이 문제를 해결하려면 문제의 병합 충돌을 해결하고 변경 사항을 추가 및 커밋해야합니다 git pull.
문제의 샘플 재현 및 해결 :
# Note: commands below in format `CUURENT_WORKING_DIRECTORY $ command params`
Desktop $ cd test
먼저 저장소 구조를 만들어 봅시다
test $ mkdir repo && cd repo && git init && touch file && git add file && git commit -m "msg"
repo $ cd .. && git clone repo repo_clone && cd repo_clone
repo_clone $ echo "text2" >> file && git add file && git commit -m "msg" && cd ../repo
repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone
이제 우리는 repo_clone에 있으며, 당신이한다면 git pull충돌을 일으킬 것입니다.
repo_clone $ git pull origin master
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/anshulgoyal/Desktop/test/test/repo
* branch master -> FETCH_HEAD
24d5b2e..1a1aa70 master -> origin/master
Auto-merging file
CONFLICT (content): Merge conflict in file
Automatic merge failed; fix conflicts and then commit the result.
복제본의 충돌을 무시하고 원래 리포지토리에서 더 많은 커밋을 수행하면,
repo_clone $ cd ../repo
repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone
그리고 git pull우리는
repo_clone $ git pull
U file
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
(가) 있습니다 file지금 병합되지 않은 상태에 있고 우리가 할 경우 git status, 우리는 분명히 같은를 볼 수 있습니다
repo_clone $ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 1 different commit each, respectively.
(use "git pull" to merge the remote branch into yours)
You have unmerged paths.
(fix conflicts and run "git commit")
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: file
따라서이 문제를 해결하려면 먼저 무시했던 병합 충돌을 해결해야합니다.
repo_clone $ vi file
내용을
text2
text1
text1
그런 다음 추가하고 변경 사항을 커밋하십시오.
repo_clone $ git add file && git commit -m "resolved merge conflicts"
[master 39c3ba1] resolved merge conflicts