Gerrit will not push. Error: No common ancestry

倾然丶 夕夏残阳落幕 提交于 2019-12-23 22:12:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!