为什么git bash不允许我推送到远程仓库?

时间:2018-12-08 21:53:13

标签: git github github-pages

我是一名新开发人员,刚刚开始学习git和github。我在github上有两个存储库,一个用于显示项目的代码,然后我进行了另一个存储库,因此我可以托管页面以使用github页面来展示该项目。我做了一个小小的更改并将提交推送到我的原始远程仓库,然后尝试将提交推送到另一个仓库,但我不断收到此错误:

Owner@MICHAEL-WORK-PC MINGW64 ~/Desktop/Coding/Dual N-Back Game Project (master|MERGING)
$ git push github master
To https://github.com/michaelacook/michaelacook.github.io
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/michaelacook/michaelacook.github.io'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我不知道为什么会这样或如何解决它,我对git还是太陌生了。有什么建议么?谢谢。

1 个答案:

答案 0 :(得分:2)

您必须先拉动。

您在远程存储库中进行了更改,而本地存储库中不存在这些更改,您必须将它们拉出并执行合并。

# pull changes
git pull origin master

# if you have a conflicts resolve them and ad your files
git add .

# commit your resolution
git commit 


# now you can push your changes
git push origin master