1

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?

sigy
  • 2,408
  • 1
  • 24
  • 55
  • You need to print the full error – Melchia Nov 30 '20 at 09:38
  • @Melchia What do you mean? I do not get any more output than what I posted. – sigy Nov 30 '20 at 09:49
  • copy paste all the logs of the error – Melchia Nov 30 '20 at 10:02
  • @Melchia Which logs do you mean? – sigy Nov 30 '20 at 10:06
  • The logs of your console – Melchia Nov 30 '20 at 10:08
  • 2
    What @Melchia means is that if the given error is from a `git push` operation, then it is not the only output. Post everything including the `git push` command and *all* of its output. – j6t Nov 30 '20 at 10:10
  • @Melchia as I said it does not print more than the error message I already posted. It seems I do not understand what you mean. Could you post the command I should execute to get the information you need? – sigy Nov 30 '20 at 10:12
  • @j6t There is no more output than what I posted. – sigy Nov 30 '20 at 10:13
  • enable verbose by adding this parameter at the end of the command --verbose – Melchia Nov 30 '20 at 10:16
  • @Melchia Ok, I updated my post. Unfortunately it does not print any more infos about the cause of the error – sigy Nov 30 '20 at 10:19
  • I suggest you reinstall git then. – Melchia Nov 30 '20 at 10:22
  • @Melchia I uninstalled git, rebooted and installed it again and rebooted. It did not work. The error persists. – sigy Nov 30 '20 at 11:08
  • YOu may be missing some libraries check your OS logs – Melchia Nov 30 '20 at 11:32
  • 1
    Set `export GIT_TRACE=2` and run `git push` again. – j6t Nov 30 '20 at 11:34
  • @j6t Thanks for your patience. I updated my question with the resulting output – sigy Nov 30 '20 at 15:49
  • 2
    Notice that a hook runs. Check what the hook in `.git/hooks/pre-push` attempts to do. Perhaps it forbids the push? – j6t Nov 30 '20 at 19:07
  • @j6t It was indeed the hook that forbid the commit and didn't print anything because of [this problem](https://stackoverflow.com/questions/3417896/). The hook was so "old" that I had not thought of it. Thanks a lot! – sigy Dec 01 '20 at 09:04
  • 1
    +1 for setting "GIT_TRACE=2" and posting the trace message! Very good - we appreciate it! But I believe this is what's happening (and what you can do about it): [git error: failed to push some refs to remote](https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote) – paulsm4 Dec 02 '20 at 07:00
  • No, it was the pre-push hook. @j6t as the question got unlocked you may post your comment as answer and I will accept it. – sigy Dec 02 '20 at 09:13

1 Answers1

1

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.

j6t
  • 9,150
  • 1
  • 15
  • 35