How to initiate Project in Gerrit

180 views
Skip to first unread message

Zohaib Shaikh

unread,
Jan 10, 2024, 4:45:25 AM1/10/24
to Repo and Gerrit Discussion
Hi

I am new to gerrit. I have created a project via Web UI 

Name: newproject (with default master branch)

Now i have code in my local directory, That's not part of any git or gerrit. Now i want to this this local code to that newproject. I did following

cd mycode
git add .
git commit "my first commit"
git remote add origin ssh://myn...@gerrit.mydomain.com:29418/myproject
git push origin HEAD:refs/for/master

I gives me error "No common ancestor" 

newproject is fresh created project on gerrit. And mu local code not part of any git or gerrit, its first time i am pushing my code to gerrit. how to resolve this error?

 


--
_________
Regards,
Zohaib

Matthias Sohn

unread,
Jan 10, 2024, 5:02:00 AM1/10/24
to Zohaib Shaikh, Repo and Gerrit Discussion
I guess you created the new project in gerrit with an initial empty commit.
If that's the case your local commit is not a successor of this initial commit.
You can fix that in the following way:
  • first fetch this initial commit from gerrit
  • rebase your local commit onto origin/master
  • then try to push again
git fetch origin
git rebase origin/master
git push origin HEAD:refs/for/master

-Matthias
Reply all
Reply to author
Forward
0 new messages