Error: failed to push some refs to ''

Jeff 1 Reputation point

I want to commit and push from Visual Studio's Team Explorer.
I chose Commit All and Push like following.
(I erased/changed some texts which has private info)


Commit seems to be OK but error occurs from push like following.

Opening repositories:
Commit 4b8791fa created locally in repository C:\WorkDir\MyProject
Pushing master
Error: failed to push some refs to ''

Error encountered while pushing branch to the remote repository: rejected master -> master (pre-receive hook declined)

Can anybody give me some advice about this error?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
2,427 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 13,071 Reputation points Microsoft Employee

    Hello Jeff,

    From the error message, it seems the error is related to pre-receive hook. As you know, the first script to run when handling a push from a client is “pre-receive”. It takes a list of references that are being pushed from stdin; if it exits non-zero, none of them are accepted. You can use this hook to do things like make sure none of the updated references are non-fast-forwards, or to do access control for all the refs and files they’re modifying with the push.

    So, I suggest you discuss with whoever maintains the repo(maybe the administrator). And then update the hook or improve your codes(changes) to let pre-receive hook pass your project.

    If you’re the maintainer, please kindly check the settings in pre-receive hook. Besides, please go to Github > your repo > Settings > Branches > Protect matching branches and check if the “Require pull request reviews before merging” option is selected. This option may affect the push action, I suggest you check if some permissions which are related to push has limitations.

    If this issue still persists, maybe it’s more related to the settings of server-side, since our forum discusses about the usage of tools and editors in Visual Studio, I recommend you go to Stack Overflow tagged with git or Stack Overflow tagged with github and start a new thread there to seek for a more professional help.


    No comments