'Gerrit will not push. Error: No common ancestry

Trying to push to gerrit. Brings up no common ancestry.

nolan@nolan-pc:~/pac-man$ git push ssh://[email protected]: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://[email protected]:29418/android_vendor_pac
 ! [remote rejected] HEAD -> refs/for/pac-6.0 (no common ancestry)
error: failed to push some refs to 'ssh://[email protected]:29418/android_vendor_pac'


Solution 1:[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.

Solution 2:[2]

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.

Solution 3:[3]

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

Solution 4:[4]

Looks you are pushing on incorrect branch . Use correct branch it will work

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Alchimic
Solution 3 Marcelo Ávila de Oliveira
Solution 4 user18168327