git无法推送到master分支

时间:2015-12-26 13:03:41

标签: git bash github

  1. github中的git repostory包含以下分支 (主人,' abc')
  2. clone git repo abc branch to local machine
  3. 使用git bash
  4. 进入repo文件夹
  5. 创建名为bbb
  6. 的git分支
  7. 结帐到分行bbb
  8. 将文件添加到repo文件夹
  9. 提交更改
  10. 将更改推送到远程repo abc分支 使用此命令:

    git push origin bbb:abc
    

    工作正常。

  11. 然后将更改推送到远程repo主分支 使用此命令:

    git push origin bbb:master
    
  12. 然后出现以下错误消息:

     ! [rejected]        bbb -> master (non-fast-forward)
    error: failed to push some refs to 'https://github.com/sw7x/testing4.git'
    hint: Updates were rejected because a pushed branch tip is behind its remote
    hint: counterpart. Check out this branch and integrate the remote changes
    hint: (e.g. 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    有人可以解释为什么会这样吗?

1 个答案:

答案 0 :(得分:4)

正如git本身所说:

hint: (e.g. 'git pull ...') before pushing again.

来自master的第一个pull(或甚至fetch),执行所需的更改,最后push。如果你是一个卑鄙的人并且关心其他人的变化,你可以使用push -f强制推动。

您收到此错误的原因是您的本地版本与github repo中的版本不同,您应该以某种方式协调这两个版本以便能够push您的代码。

相关问题