首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git推送-u源站失败

git推送-u源站失败
EN

Stack Overflow用户
提问于 2017-03-28 09:32:36
回答 2查看 828关注 0票数 3

我已经完成了R (Coursera课程)的第二个编程作业。

在那之后,我确实在我的GitHub帐户上将我的本地存储库与全局存储库关联,然后我进行了提交和push -u origin master

但我得到了以下错误:

代码语言:javascript
复制
 ! [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,但我收到了以下消息:

代码语言:javascript
复制
 ! [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.

我该如何继续呢?

EN

回答 2

Stack Overflow用户

发布于 2018-02-15 00:30:41

如果您在将代码推送到存储库之前添加许可证或自述文件,则会发生这种情况。

票数 1
EN

Stack Overflow用户

发布于 2017-03-28 12:54:45

如果您的提交是在专用分支上,请尝试:

代码语言:javascript
复制
git fetch
git checkout mybranch (you might be already on that branch)
git rebase origin/master
git push -u origin mybranch

但是,如果您的提交是在本地主分支上,并且如果您应该在主分支上推送,那么:

代码语言:javascript
复制
git checkout master
git fetch

# replay your local commits on top of origin/master
git pull --rebase
# check everything is still working

git push
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43059157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档