Frage

https://review.openstack.org/#/c/64401/

Above is the commit I'm trying to amend

git commit -a --amend

But when I do

git review -v

It gives me

Running: git log --color=never --oneline HEAD^1..HEAD
Running: git remote
Running: git branch -a --color=never
Running: git branch --color=never
Running: git log HEAD^1..HEAD
Found topic 'fix-bug-1187277' from parsing changes.
Running: git rev-parse --show-toplevel
Running: git remote update gerrit
Fetching gerrit
Running: git rebase -i remotes/gerrit/master
Errors running git rebase -i remotes/gerrit/master
error: could not apply a062f76... Modify API ref for per-project-user quotas CRUD methods

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".
Could not apply a062f76... Modify API ref for per-project-user quotas CRUD methods

I don't quite understand what I need to do here? I tried git rebase --abort git rebase --skip git rebase --continue, didn't solve it.

War es hilfreich?

Lösung

That there, that right there, is a git conflict. Your commit a062f76 - Modify API ref for per-project-user quotas CRUD methods is modifying lines that remotes/gerrit/master has also modified.

This stackoverflow answer explains resolving conflicts in git. It is your best link for knowledge, straight-up. But here's my take:

Run git diff to see what the conflicts are: you'll find lines from HEAD (theirs) and lines from your commit (ours). Perhaps you will see merged common ancestors, which I find confusing and unhelpful. Find those lines in your code and fix them up so that the final state is what both parties want the code to do. Be wary because you may be deciding to delete lines that someone else meant to be there, or obfuscate the code. Personally, I prefer to find and talk with the author of the conflicting lines about them, to avoid such problems.

Or, on each of the paths (read: files) affected, you could run git checkout [--theirs|--ours] -- path/to/file to move that path to a certain point, where theirs is the HEAD's last commit to that path and ours is your last commit. The former says "I don't want my code", and the latter says "I want only my code, no one elses".

Once you're happy, git rebase --continue should work. You may have to repeat these steps again if another conflict is found.

Reading material

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top