5

I'm having trouble pushing commits on a hotfix branch created with git-flow to the remote repository.

Here is the error:

$ git push origin hotfix/MyHotfix
Counting objects:
... etc
To {my remote repo}
 ! [remote rejected] hotfix/MyHotfix -> hotfix/MyHotfix (no such ref)
error: failed to push some refs to {my remote repo}

I created the hotfix with the standard syntax:

git flow hotfix start MyHotfix

and this branch is already present on the origin, which I can see with git branch -a. I have also checked that the branch is still present on the remote server, since it shows up when I run git remote show origin.

Has anyone come across this before with git or git-flow and found a solution?

Note - things I have tried:

  • Re-cloning the remote repo -> same error
  • Deleting the local branch -> same error
  • Deleting the remote branch -> I can push the 'new' branch, but get the same error on my colleagues local repo when he tries to push a commit (after git remote prune origin)
  • Force push -> same error
  • Upstream push -> same error
  • Checking refs -> my commit parent id matches the server

Update:

git ls-remote origin and git show-ref show different refs for the local and remote hotfix branches, but this is because I have 1 extra commit locally, and the parent commit's ref matches the ref on origin.

Laurence
  • 1,673
  • 11
  • 16

2 Answers2

3

It looks like it was actually a problem with the server repository. Running these steps on the bare repo on the server cleared up the error:

git fsck --full
git prune
git gc

Note: according to the man pages git prune isn't required because git gc calls it, but I was trying everything.

Laurence
  • 1,673
  • 11
  • 16
1

Considering issue 92, I don't think hotfix branches are meant to be published.
This is a feature request which is still pending.

While release and feature branches can all be published (git flow release/feature publish), hotfix branches cannot.

So maybe the push itself has been prevented to be compliant with the (already denied) publish operation.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I have previously been able to push the hotfix branch (since it is visible on origin) and I also tested `git flow hotfix publish Test`, which worked. I think issue 92 should actually be closed (and there is an associated pull request which is closed) – Laurence Feb 07 '13 at 21:30
  • @Laurence then this branch must have been deleted on `origin`: what `git push -u origin hotfix/MyHotfix:hotfix/MyHotfix` returns? – VonC Feb 07 '13 at 21:42
  • That command gives the same error. I'm wondering if there is a mismatch between the branch name<->ref mapping on `origin` and on my machine. Is there a way to check this? – Laurence Feb 08 '13 at 13:45
  • @Laurence `git fetch` followed by a `git branch -a` would give you the name of the remote branches (as well as the local ones). – VonC Feb 08 '13 at 14:06
  • Thanks @VonC, but I know the branch is present on the remote, it shows up with `git fetch && git branch -a` and also with `git remote show origin` – Laurence Feb 08 '13 at 14:29