我在R(Coursera课程)完成了第二个编程作业
之后,我确实将我的本地仓库与我的GitHub帐户上的全局仓库相关联,然后我做了一个提交并push -u origin master
。
但是我收到了以下错误:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/RofaidaG/ProgrammingAssignment2'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first 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.
然后我做了一个分支并结账给主人,然后在我的获取帐户中拉回购,但我收到了以下消息:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to
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.
我该怎么办?
答案 0 :(得分:0)
如果您的提交位于专用分支上,请尝试改为:
[
{'Job' : 'Sailor', 'People' : ['Martin', 'Andrew']},
{'Job' : 'Teacher', 'People' : ['Alex', 'Maria']}
]
但是如果你的提交是在本地主分支上,并且如果你应该推动master,那么:
git fetch
git checkout mybranch (you might be already on that branch)
git rebase origin/master
git push -u origin mybranch
答案 1 :(得分:0)
如果在将代码推送到存储库之前添加许可证或README文件,则会发生这种情况。