简体   繁体   English

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

[英]Why won't git bash allow me to push to my remote repo?

I am a new developer and just began learning git and github. 我是一名新开发人员,刚刚开始学习git和github。 I have two repos on github, one to show the code for a project and then I made another so I could host the page to show off the project with github pages. 我在github上有两个存储库,一个用于显示项目的代码,然后我进行了另一个存储库,因此我可以托管页面以使用github页面来展示该项目。 I made a small change and pushed the commit to my original remote repo, and then tried to push the commit to the other repo and I keep getting this error: 我做了一个小小的更改并将提交推送到我的原始远程仓库,然后尝试将提交推送到另一个仓库,但我不断收到此错误:

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.

I have no idea why this is happening or how to fix it, I'm too new to git. 我不知道为什么会这样或如何解决,我对git来说还太陌生。 Any suggestions? 有什么建议么? Thanks. 谢谢。

You must pull before you push. 您必须先拉,然后再推动。

You have changes in your remote repository which does not exist in your local and you must pull them and perform a merge. 您在本地本地不存在的远程存储库中进行了更改,必须将它们拉出并执行合并。

# 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM