git push fails for develop/master

245 views Asked by At

When trying to push from local branches master or develop to their corresponding remote version I receive nothing more but the following error

$ git push --verbose
Pushing to server-name:repo-name/repo.git

error: failed to push some refs to 'server-name:repo-name/repo.git'

Pushing other branches succeeds. I can also push to our develop and master branch from other local branches e.g. the following works

git checkout master
git checkout -b master2
git push origin master2:master

Our repository is a self-hosted GitLab instance of which I am the owner. Because of that and because pushing from a different local branch succeeds I do not think it is a permission problem. I tried to completely delete my local versions of develop and master and checkout a clean version but to no avail.

EDIT
As asked in the comments I did set GIT_TRACE=2 and ran git push again. This is the full output:

$ git push
16:41:50.788861 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
16:41:50.791871 git.c:444               trace: built-in: git push
16:41:50.800860 run-command.c:663       trace: run_command: unset GIT_PREFIX; ssh git@server-name 'git-receive-pack '\''repo-name/repo.git'\'''
16:41:51.703871 run-command.c:663       trace: run_command: .git/hooks/pre-push origin git@server-name:repo-name/repo.git
16:41:51.743860 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
16:41:51.744861 git.c:444               trace: built-in: git rev-parse --abbrev-ref HEAD

error: failed to push some refs to 'server-name:repo-name/repo.git'
16:41:51.893859 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
16:41:51.895871 git.c:444               trace: built-in: git config --bool core.sparseCheckout

I compared the output with a machine where git push is working and noticed that it prints Everything up-to-date after running git-receive-pack. So I assume that my machine fails to compare the received refs with my local refs?

1

There are 1 answers

0
j6t On BEST ANSWER

It is somewhat surprising that git push responds with

error: failed to push some refs to 'server-name:repo-name/repo.git'

and nothing else. But your trace shows that Git runs a hook:

16:41:51.703871 run-command.c:663       trace: run_command: .git/hooks/pre-push origin git@server-name:repo-name/repo.git

The manual of the pre-push hook tells:

This hook is called by git-push[1] and can be used to prevent a push from taking place.

[...]

If this hook exits with a non-zero status, git push will abort without pushing anything. Information about why the push is rejected may be sent to the user by writing to standard error.

An that is what happened in your case. It looks like the only error that was printed was an empty line.