Programing

Git rebase-모든 병합 충돌이 해결 된 경우에도 계속 불평

lottogame 2020. 9. 1. 07:56
반응형

Git rebase-모든 병합 충돌이 해결 된 경우에도 계속 불평


해결 방법을 잘 모르겠습니다.

내 지점에서 마스터에 대한 리베이스를 수행했습니다.

git rebase master

다음과 같은 오류가 발생했습니다.

 First, rewinding head to replay your work on top of it...
 Applying: checkstyled.
 Using index info to reconstruct a base tree...
 Falling back to patching base and 3-way merge...
 Auto-merging AssetsLoader.java
 CONFLICT (content): Merge conflict in AssetsLoader.java
 Failed to merge in the changes.
 Patch failed at 0001 checkstyled.

그래서 내가 좋아하는 편집기로 가서 1 줄 충돌을 수정하고 파일을 저장하고 git 상태를 수행하고 다음 출력을 얻었습니다.

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #  modified:   PassengerContactHandler.java
 #
 # Unmerged paths:
 #   (use "git reset HEAD <file>..." to unstage)
 #   (use "git add/rm <file>..." as appropriate to mark resolution)
 #
 #  both modified:      AssetsLoader.java
 #

나는 git add AssetsLoader.java 및 git status를 수행하고 다음을 얻었습니다.

 # Not currently on any branch.
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #  modified:   AssetsLoader.java
 #  modified:   PassengerContactHandler.java
 #

그리고 내가 git rebase --continue했을 때 다음을 얻습니다.

git rebase --continue
You must edit all merge conflicts and then
mark them as resolved using git add

패치를 건너 뛰고 리베이스를 계속할 수 있다는 것을 알고 있지만 PassengerContactHandler.java의 변경 사항이 내 브랜치에 리베이스 될지 여부는 확실하지 않습니다.

잘 모르겠습니다. 어떻게 진행해야하나요?

편집 : 충돌이 해결 된 파일이 원래 버전과 똑같을 수 있습니까?

고마워, Lucas

편집, 그것은 나에게 다시 일어났습니다.

다시 나에게 일어난 일

(307ac0d...)|REBASE)$ git status
# Not currently on any branch.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   assets/world/level1/Level-1.xml
#   modified:   George.java
#   modified:   DefaultPassenger.java
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   mb-art/originalAssets/27dec/

((307ac0d...)|REBASE)$ git rebase --continue

You must edit all merge conflicts and then
mark them as resolved using git add

git --version

git version 1.7.1

This happens because when fixing a conflict, you removed all code in the patch beeing applied to the branch you are rebasing on. Use git rebase --skip to continue.

A bit more details:

Normally, when fixing a conflict during rebasing, you will edit the conflicting file, keeping some or all of the code in the patch currently being applied to the branch you rebase on. After fixing the patch and doing

git add your/conflicted/file
git status

you will get a (usually green) line showing the modified file

modified: your/conflicted/file

git rebase --continue will work fine in this situation.

Sometimes, however, when resolving the conflict, you remove everything in your new patch, keeping only code from the branch you rebased on. Now when you add the file, it will be exactly like the one you tried to rebase on. git status will show no green line displaying the modified files. Now, if you do

git rebase --continue

git will complain with

No changes - did you forget to use 'git add'?

What git actually wants you to do in this situation is to use

git rebase --skip

to skip the patch. Previously I never did this, as I was always unsure what would actually be skipped if I did, it was not obvious to me what "skip this patch" really meant. But if you get no green line with

modified: your/conflicted/file

after editing the conflicted file, adding it, and doing git status, then you can be pretty sure you removed the whole patch, and you can instead use

git rebase --skip

to continue.

The original post said this sometimes works:

git add -A
git rebase --continue
# works magically?

... but don't rely on this (and be sure not to add leftover files in your repository folders)


Seems to be a bug in Git 1.7

Here's a good article on how to solve this.

Basically it should work, if you do a

git diff

after resolving your conflicts and then

git rebase --continue

should work.


Try running this in your command line:

$ git mergetool

Should bring up an interactive editor allowing you to resolve the conflicts. Easier than trying to do it manually, and also git will recognize when you do the merge. Will also avoid situations where you don't fully merge by accident that can happen when you try to do it manually.


Ive just had this problem, and whilst I think there might be a few causes, here's mine...

I had a git pre-commit hook which rejected commits under certain conditions. This is fine when committing manually, since it will display the output of the hook, and I can either fix it or choose to ignore it using commit --no-verify.

The problem seems to be that when rebasing, rebase --continue will also call the hook (in order to commit the lastest bout of changes). But rebase will not display the hook output, it'll just see that it failed, and then spit out a less specific error saying 'You must edit all merge conflicts and then mark them as resolved using git add'

To fix it, stage all your changes, and instead of doing 'git rebase --continue', try a 'git commit'. If you are suffering from the same hook problem, you should then see the reasons why its failing.

Interestingly, whilst git rebase doesn't display the output from git hook, it does accept a --no-verify to bypass the hooks.


You missed a merge conflict in AssetsLoader.java. Open it up and look for conflict markers (">>>>", "====", "<<<<<") and then do git add again. Do a 'git diff --staged' if you're having difficulty finding it.


After fixing the conflict, make sure the changed files(s) are added to your staged files. This solved the problem for me.


I got this warning when I had unstaged files. Make sure you don't have any unstaged files. If you don't want the unstaged files changes, then discard the changes with git rm <filename>.

참고URL : https://stackoverflow.com/questions/8523776/git-rebase-continue-complains-even-when-all-merge-conflicts-have-been-resolved

반응형