我已经完成了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.然后我创建了一个分支并结帐到主服务器,然后在我的get帐户中提取repo,但我收到了以下消息:
! [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.我该如何继续呢?
发布于 2018-02-15 00:30:41
如果您在将代码推送到存储库之前添加许可证或自述文件,则会发生这种情况。
发布于 2017-03-28 12:54:45
如果您的提交是在专用分支上,请尝试:
git fetch
git checkout mybranch (you might be already on that branch)
git rebase origin/master
git push -u origin mybranch但是,如果您的提交是在本地主分支上,并且如果您应该在主分支上推送,那么:
git checkout master
git fetch
# replay your local commits on top of origin/master
git pull --rebase
# check everything is still working
git pushhttps://stackoverflow.com/questions/43059157
复制相似问题