Gerrit code review push to empty repo doesn't work
Asked Answered
F

1

8

I installed and configured my own Gerrit server. I created a repository using the web gui for Gerrit. I am able to clone this empty repository succesfully using the "git" command, so the configuration seems to be fine. Next, I:

  1. configured my access: git config --global user.email ..., git config --global user.name ...,

  2. added remote: git add remote origin myUser@myGitHost:29418/project.git,

  3. created and commited file: git add file, git commit -m "first commit".

So far so good.

But, when I try to push it to my repo, I get output:

myUser@myGitHost:~/project$ git push origin master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 525 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To ssh://myUser@myGitHost:29418/project.git
 ! [remote rejected] master -> master (can not update the reference as a fast forward)
error: failed to push some refs to 'ssh://myUser@myGitHost:29418/project.git'

I tried to look for solution. The "git pull origin master" does not work. Pushing with -f option isnt working too.

Can anyone help me?

EDIT: The output of push -f:

myUser@myGitHost:~/project$ git push -f origin master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 525 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
To ssh://myUser@myGitHost:29418/project.git
 ! [remote rejected] master -> master (can not update the reference as a fast forward)
error: failed to push some refs to 'ssh://myUser@myGitHost:29418/project.git'

What I mean by The "git pull origin master" is that the most solution ppl mention is to do a pull before push, for example: http://rip747.wordpress.com/2009/04/20/git-push-rejected-non-fast-forward/. This pull outputs:

myUser@myGitHost:~/project$ git pull origin master
From ssh://myGitHost:29418/project
 * branch            master     -> FETCH_HEAD
Already up-to-date.

But when I do a push, the output is still the same:

can not update the reference as a fast forward.

Ferromanganese answered 18/8, 2012 at 17:23 Comment(2)
Please show output of push -f. What do you mean, that pull origin master does not work?Tudor
Hi, thanks for your feedback. I added an "Edit" section to my post, in order to answer your questions.Melton
B
7

Are you trying to bypass the code-review feature of Gerrit? If not, try git push origin HEAD:refs/for/master

Belmonte answered 19/8, 2012 at 16:17 Comment(3)
Ok, thanks - when I do as you re telling, it says " ! [remote rejected] HEAD -> refs/for/master (invalid committer)" I will manage to fix this. But what if I want to bypass code review? If I do git push origin HEAD:refs/heads/master I still get " ! [remote rejected] HEAD -> master (can not update the reference as a fast forward)". It says in the documentation that this is possible to bypass the code review. So the problem seems to be in Git itself, not in gerrit?Melton
OK, according to this: mediawiki.org/wiki/Thread:User_talk:%5Edemon/… I need ammend some .gitreview file to push directly. How can I do this (push firectly) without adding this file?Melton
I'd like to answer my previous comment, because I figured it out in answer to post: #7424393Melton

© 2022 - 2024 — McMap. All rights reserved.