问题
Trying to push to gerrit. Brings up no common ancestry.
nolan@nolan-pc:~/pac-man$ git push ssh://1KX2@review.pac-rom.com:29418/android_vendor_pac HEAD:refs/for/pac-6.0
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 6.63 KiB | 0 bytes/s, done.
Total 8 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To ssh://1KX2@review.pac-rom.com:29418/android_vendor_pac
! [remote rejected] HEAD -> refs/for/pac-6.0 (no common ancestry)
error: failed to push some refs to 'ssh://1KX2@review.pac-rom.com:29418/android_vendor_pac'
回答1:
One case where this is solved "easily" is if you pushed to an entirely new repo and have no interest in any possibly old git history that brought your project code to the state it has now.
Then a solution is to start in a new folder, then clone the (empty) project from gerrit. This folder then have a common ancestry with this gerrit project. Then you could work to add your source files into this new folder using git add until satisfied,(that mundane work is the non-easy part) leaving out any old .git folder and finally try a push. This pushes your project onto gerrit with git history beginning from this point on.
回答2:
This happens because your local development history is totally independent of the development history of the pac-6.0 branch. They don't have a common ancestry.
See more info here:
https://gerrit-review.googlesource.com/Documentation/error-no-common-ancestry.html
回答3:
I know this is a long time, but in my case, I used automatic rebase from gerrit interface to resolve simple conflicts. Maybe this introduce some changes between my local repository and the server one.
I simply had to sync with git to get those updates.
Using the git pull --rebase origin master
worked for me.
来源:https://stackoverflow.com/questions/38066069/gerrit-will-not-push-error-no-common-ancestry