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.

Rafał
  • 582
  • 1
  • 9
  • 14
  • Please show output of `push -f`. What do you mean, that `pull origin master does not work`? – Greg Aug 18 '12 at 18:27
  • Hi, thanks for your feedback. I added an "Edit" section to my post, in order to answer your questions. – Rafał Aug 19 '12 at 09:55

1 Answers1

7

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

Brad
  • 5,492
  • 23
  • 34
  • 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? – Rafał Aug 20 '12 at 06:53
  • OK, according to this: http://www.mediawiki.org/wiki/Thread:User_talk:%5Edemon/Something_is_missing_or_I'm_missing_something_in_a_last_migrated_extension/reply_(2) I need ammend some .gitreview file to push directly. How can I do this (push firectly) without adding this file? – Rafał Aug 20 '12 at 09:14
  • I'd like to answer my previous comment, because I figured it out in answer to post: http://stackoverflow.com/questions/7423893/git-alias-for-headrefs-for-master/12042176#12042176 – Rafał Aug 20 '12 at 17:27