Can't push refs to remote try running pull first to integrate your changes

后端 未结 4 1323
抹茶落季
抹茶落季 2020-12-16 04:41

I keep getting this error when I try to push to GitHub from VScode. I\'ve pushed before to that repository following the exact same steps I am following now. Can\'t find an

相关标签:
4条回答
  • 2020-12-16 05:13

    I got a similar issue, try these below cases any one of the below cases might solve your issue:

    1. After resolving merge conflicts, it's expecting you to commit your changes:
      git commit -m "resolved merge conflicts or any other message"
    2. Click on "git pull from" option in VSCode and resolve conflicts, if any.
    3. git pull --rebase origin develop.
    0 讨论(0)
  • 2020-12-16 05:27

    I was getting this message in my Azure DevOps Repos environment because the server had a branch policy on the master branch that requires pull request approval and I was trying to push to master directly. Even after pull and rebase the same message appears. I don't think VS Code really knows how to interpret this specific error coming back from the server so it gives the generic message. If I try the same push with git directly it shows a remote rejected error that explains the problem. So my answer only applies in this 1 narrow case, but it can definitely cause the same error message to appear when pushing in VS Code.

    0 讨论(0)
  • 2020-12-16 05:36

    You get this try running pull first to integrate your changes whenever your local branch and your remote branch are not on the same point, before your changes.

    remote branch commits : A -> B -> C -> D
    local branch commits  : A -> B -> C -> Local_Commits 
    

    Now clearly, there's a change D that you don't have integrated locally. So you need to rebase, then push, which will lead to the following.

    remote branch commits : A -> B -> C -> D
    local branch commits  : A -> B -> C -> D -> Local_Commits 
    

    To solve your issue, do the following

    git pull --rebase origin branchname
    git push origin branchname
    
    0 讨论(0)
  • 2020-12-16 05:36

    One possible reason that you get the "Failed to push some refs" error is that you do not have enough permission to push to the current branch (probably master). You need to ask project maintainers to give you enough permission or you need to push your changes to another branch and make a merge/pull request.

    0 讨论(0)
提交回复
热议问题