首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法推送到github,看起来拉没有更新我的远程分叉

无法推送到github,看起来拉没有更新我的远程分叉
EN

Stack Overflow用户
提问于 2014-01-17 21:13:57
回答 1查看 133关注 0票数 0

有一些问题推动我在github的分叉回购

见当前状态

代码语言:javascript
复制
$ git remote -v
origin  git@github.com:claudio4j/hal-core (fetch)
origin  git@github.com:claudio4j/hal-core (push)
upstream        git://github.com/hal/core.git (fetch)
upstream        git://github.com/hal/core.git (push)

$ git branch -v
* gui_enhancements c1adba1 remove backup pom.xml~ file
  master           5128b4d HAL-335: Workaround using include-aliases=true; more fail-safe RBACGatekeeper

$ git status
# On branch gui_enhancements
nothing to commit, working directory clean

$ git pull --rebase upstream master
From git://github.com/hal/core
 * branch            master     -> FETCH_HEAD
Current branch gui_enhancements is up to date.

推失败了。

代码语言:javascript
复制
$ git push origin gui_enhancements
To git@github.com:claudio4j/hal-core
 ! [rejected]        gui_enhancements -> gui_enhancements (non-fast-forward)
error: failed to push some refs to 'git@github.com:claudio4j/hal-core'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

看来我的分叉回购没有更新,与上游叉子相比:enhancements上游:https://github.com/hal/core/commits/master

"git拉“不是更新了我的叉子回购吗?

这就是我不能推的原因吗?

谢谢你的帮助。

克劳迪奥

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-17 21:45:24

git pull --rebase做一个fetch,后面跟着一个rebase。在新主服务器之上重定位重放提交,因此它“更改历史”;gui_enhancements尖端的旧提交并不是新提交的祖先。

如果您是唯一一个在叉子上使用这个分支的人(可能就是这样),那么您所需要做的就是:

代码语言:javascript
复制
git push -f origin gui_enhancements

-f将强行推动通过。

如果你的叉子上有其他人和你在这个分支上合作,那么重写历史会让事情变得尴尬,你可能应该使用真正的(非rebase)拉。以这种方式重做事情:

代码语言:javascript
复制
# I'm taking the sha that your branch used to be on from the output you pasted.
git reset --hard c1adba1

# No --rebase option.
git pull upstream master

# Since "git pull" did a merge commit this time, it'll be a descendant of the
# old gui_enhancements ref on origin, and the push should succeed.
git push
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21195988

复制
相关文章

相似问题

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