1
  1. I have a repo with a remote branch master and a local branch temp that I'm working in.
  2. I'm working with gerrit, so pushing my local with git push origin HEAD:refs/for/master rather than git push. This has been working perfectly fine.

My temp branch was setup to mirror the remote master originally, but the remote master is being abandoned, changed to work.

So I ran these commands:

git branch --set-upstream temp origin/work

git commit

Both worked.

Now, I try git push origin HEAD:refs/for/work

It gets rejected, claiming I have no new changes.

Yet when I run git status, it says my local branch is ahead of origin/work by 1 commit.

I'm totally confused. Any ideas?

Additional Info

-I have also tried git rebase origin/work with the temp branch checked out, which resulted in: "Current branch temp is up to date.`

-svlasov, I tried your suggestion of: git fetch origin, thengit status

This tells me I am ahead by 1 commit.

Git Version

1.7.9.5

krb686
  • 1,726
  • 9
  • 26
  • 46
  • What if you first try `git fetch origin`, then `git status`? – svlasov Feb 27 '15 at 16:56
  • @svlasov I added some info under "Additional Info" – krb686 Feb 27 '15 at 17:02
  • How about `git log origin/work..HEAD`? – svlasov Feb 27 '15 at 17:04
  • What version of git are you using? I thought it was changed to --set-upstream-to a long time ago – Nadine Feb 27 '15 at 17:08
  • @svlasov This shows the most recent commit that I am trying to push – krb686 Feb 27 '15 at 17:08
  • @highonprogramming Sorry I should have included that in the post, it is there now. It is 1.7.9.5, so just before it changed in 1.8. I am not in a position to change it either, unfortunately. – krb686 Feb 27 '15 at 17:09
  • Why don't you push as `git push origin work`? – svlasov Feb 27 '15 at 17:13
  • @svlasov So I just tried that actually, and it didn't work, but it also didn't do what I expected. It came back with *Everything up-to-date.". Yet I was expecting it to reject it. With gerrit, I don't push directly to the branch, it goes through another branch called "refs/for/ where it gets reviewed, and then pushed to the primary branch – krb686 Feb 27 '15 at 17:15
  • This command should show you which branch temp is tracking: git branch -vv | grep temp Make sure it's origin/work – Nadine Feb 27 '15 at 17:15
  • @highonprogramming The result of that is: `temp.....30117b4 [origin/work: ahead 1] commit message header`. I was thinking that since it is tracking `origin/work`, yet I am not directly pushing to `origin/work`, could there be an inconsistency inside gerrit? This still doesn't make complete sense though, since the `refs/for/work` branch should NOT have my commit yet. And also, I've never encountered that problem with gerrit before. In the past, I have made my branches track `master` and pushed to `refs/for/master` without an issue – krb686 Feb 27 '15 at 17:17
  • I know this is a stupid suggestion, but I'm running out of ideas. Are you sure you're on the right branch? – Nadine Feb 27 '15 at 17:21
  • @highonprogramming Yep, absolutely sure. I run `git branch`, and I see my list of branches, with a `*` and the text colored green on the branch `temp`. Thanks for the ideas though, maybe this is a gerrit issue and not a git issue? – krb686 Feb 27 '15 at 17:22
  • I'm not familiar with gerrit, but I found this in their documentation: "If you attempt to do 'git push' after doing 'git commit' you may receive a response 'Everything up-to-date'. You have not pushed to the branch. You have to do 'git review' to move your changes to gerrit, and only from gerrit will the branch be updated." Maybe you need to do git review? – Nadine Feb 27 '15 at 17:32
  • @highonprogramming Thanks, I'll have to try that in the future to see if it works. I resolved this error by just deleting my `temp` branch, pulling the new remote `work`, and branching off of my local `work` to a new `temp`, and applying my changes there and pushing. Not sure why attempting to change the upstream tracked branch from the old `master` to the new `work` made git so fussy. – krb686 Feb 27 '15 at 17:42
  • I guess you should add that as an answer and accept it then. Git does act up every once in a while, though I'm not sure the issue wasn't from gerrit – Nadine Feb 27 '15 at 17:43
  • This is definitely a gerrit issue, not git. Can't remember the cause, but it hits me occasionally. If I can track down a definitive answer, I'll post it. – kdopen Feb 27 '15 at 23:35
  • Got it: see http://stackoverflow.com/questions/13992229/git-gerrit-push-remote-rejected-no-changes-made – kdopen Feb 27 '15 at 23:37

0 Answers0