your programing

Git Pull이 불가능하고 병합되지 않은 파일

lovepro 2020. 10. 4. 12:56
반응형

Git Pull이 불가능하고 병합되지 않은 파일


나는 이것에 대한 유사한 질문을 모두 읽었습니다. 다음 중 어느 것도 작동하지 않은 것 같습니다.

Delete offending files
git reset --hard HEAD
git stash
git pull

거의 모든 조합, 변경 사항을 숨기고 저장소에서 가져 오면 병합 할 수없는 파일이 생성됩니다. 모든 로컬 변경 사항을 삭제하고 리모컨 만 사용하고 싶지만 다시 복제 할 수 없습니다 (이 작업을 수행하려는 개발자의 대역폭 및 인터넷 사용 제한). 어떻게해야합니까?

방금 시도 :

git stash
git pull

또한 작동하지 않았습니다.

더 많은 정보

로컬 커밋이 하나 있고 업스트림에도 커밋이 있습니다. 이렇게 시도 git pull --rebase했지만 여전히 제대로 작동하지 않습니다. "해결되지 않은 충돌로 인해 종료"오류가 발생합니다. 이 경우 git stash, git reset --hard HEAD, git pull --rebase"pull is not possible, unmerged changes ..."라는 오류 메시지가 표시됩니다.


리모컨이 origin이고 브랜치가 master이고 이미 master체크 아웃 했다고 말하면 다음을 시도 할 수 있습니다.

git fetch origin
git reset --hard origin/master

이것은 기본적으로 현재 분기를 가져 와서 HEAD원격 분기 를 가리 킵니다 .

경고 : 코멘트에 명시된 바와 같이, 이 로컬 변경을 멀리 던질 것이다기원에 무엇이든 덮어 쓰기 .

또는 배관 명령을 사용하여 기본적으로 동일한 작업을 수행 할 수 있습니다.

git fetch <remote>
git update-ref refs/heads/<branch> $(git rev-parse <remote>/<branch>)
git reset --hard

편집 : 왜 이것이 작동하는지 간략하게 설명하고 싶습니다.

.git폴더 저장소의 수에 대한 커밋을 보유 할 수 있습니다. 커밋 해시는 실제로는 무작위로 생성 된 값이 아니라 커밋 내용에 대한 확인 방법이므로 저장소간에 커밋 세트를 일치시키는 데 사용됩니다.

분기는 주어진 해시에 대한 명명 된 포인터입니다. 다음은 세트의 예입니다.

$ find .git/refs -type f
.git/refs/tags/v3.8
.git/refs/heads/master
.git/refs/remotes/origin/HEAD
.git/refs/remotes/origin/master

이러한 각 파일에는 커밋을 가리키는 해시가 포함되어 있습니다.

$ cat .git/refs/remotes/origin/master
d895cb1af15c04c522a25c79cc429076987c089b

이들은 모두 내부 git 저장 메커니즘을위한 것이며 작업 디렉토리 와 독립적으로 작동 합니다. 다음을 수행합니다.

git reset --hard origin/master

git은 origin / master가 가리키는 동일한 해시 값에서 현재 분기를 가리 킵니다. 그런 다음 해당 해시의 파일 구조 / 내용과 일치하도록 작업 디렉토리를 강제로 변경합니다.

직장에서 이것을 보려면 계속해서 다음을 시도하십시오.

git checkout -b test-branch
# see current commit and diff by the following
git show HEAD
# now point to another location
git reset --hard <remote>/<branch>
# see the changes again
git show HEAD

나는 운이 좋았다

git checkout -f <branch>

비슷한 상황에서.

http://www.kernel.org/pub//software/scm/git/docs/git-checkout.html

GIT에서 삭제 취소


다음 명령 세트를 사용하여 해결되었습니다.

git reset --hard
git pull --rebase
git rebase --skip
git pull

The trick is to rebase the changes... We had some trouble rebasing one trivial commit, and so we simply skipped it using git rebase --skip (after having copied the files).


Assuming you want to throw away any changes you have, first check the output of git status. For any file that says "unmerged" next to it, run git add <unmerged file>. Then follow up with git reset --hard. That will git rid of any local changes except for untracked files.


I got solved with git remove the unmerged file locally.

$ git rm <the unmerged file name>
$ git reset --hard
$ git pull --rebase
$ git rebase --skip
$ git pull
Already up-to-date.

When I send git commit afterward:

$ git commit . -m "my send commit"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

If you ever happen to get this issue after running a git fetch and then git is not allowing you to run git pull because of a merge conflict (both modified / unmerged files, and to make you more frustrated, it won't show you any conflict markers in the file since it's not yet merged). If you do not wish to lose your work, you can do the following.

stage the file.

$ git add filename

then stash the local changes.

$ git stash

pull and update your working directory

$ git pull

restore your local modified file (git will automatically merge if it can, otherwise resolve it)

$ git stash pop

Hope it will help.


There is a solution even if you don't want to remove your local changes. Just fix the unmerged files (by git add or git remove). Then do git pull.


Ryan Stewart's answer was almost there. In the case where you actually don't want to delete your local changes, there's a workflow you can use to merge:

  • Run git status. It will give you a list of unmerged files.
  • Merge them (by hand, etc.)
  • Run git commit

Git will commit just the merges into a new commit. (In my case, I had additional added files on disk, which weren't lumped into that commit.)

Git then considers the merge successful and allows you to move forward.

참고URL : https://stackoverflow.com/questions/15127078/git-pull-is-not-possible-unmerged-files

반응형