2

I am trying to do a git push as shown below

git push origin HEAD:refs/master 

It is giving the below logs

Counting objects: 24, done. Delta compression using up to 12 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 454 bytes | 0 bytes/s, done. Total 4 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 0% (0/1) To ssh://deepu.t@... 

I am getting below error after that

! [remote rejected] HEAD -> refs/master (ref exists) 

I have searched and couldn't find anything related to this error.

(ref exits)

Please help!!

4
  • What a strange way to push. Are you just trying to push work to master? Commented Oct 8, 2015 at 19:53
  • I was missing "for"!! Commented Oct 8, 2015 at 20:06
  • @Makoto this is because of Deepu is using Gerrit Commented Oct 8, 2015 at 20:17
  • @StephenKing: Alright, fair enough. Commented Oct 8, 2015 at 20:20

1 Answer 1

5

The correct refspec for the master branch is either master or refs/heads/master. So either one of the following should work:

git push origin HEAD:master git push origin HEAD:refs/heads/master 

As you appear to be using Gerrit (I'm assuming because you've used the tag in your question), you might not be authorized to push directly into the master branch, depending on how your Gerrit is configured. If you intend to push your changes into code-review instead of directly into the master branch, use the refs/for/master refspec:

git push origin HEAD:refs/for/master 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, yes I am using gerrit and git push origin HEAD:refs/for/master worked.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.