Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法推送到github,看起来像是拉不到';t更新我的远程fork_Git_Github - Fatal编程技术网

无法推送到github,看起来像是拉不到';t更新我的远程fork

无法推送到github,看起来像是拉不到';t更新我的远程fork,git,github,Git,Github,有一些问题促使我在github提交了一些分叉回购协议 查看当前状态 $ 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 (

有一些问题促使我在github提交了一些分叉回购协议

查看当前状态

$ 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.
推送失败

$ 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.
与上游相比,我的分叉回购似乎没有更新 叉子: 上游:

“git pull”没有更新我的分叉回购协议吗

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

谢谢你的帮助

Claudio

git pull--rebase
执行
获取
,然后执行
rebase
。重定基址将在新主控台上重放提交,因此它“更改历史”;位于
gui\u增强
顶端的旧提交不是新提交的祖先

如果你是唯一一个在你的叉子上使用这个分支的人,那么你需要做的就是:

git push -f origin gui_enhancements
-f
将强制推送

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

# 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

因为这是分叉回购,只有我在工作,我做了一次强制推送,它成功了。嗨,Ash,当你说“gui_增强尖端的旧提交不是新提交的祖先”时,你看到了吗?如何检查?感谢:)重定基址的工作方式是创建新的提交,该提交与原始提交做相同的工作,但在新的父级上;因此,重新定基操作的内在特性是,它会像这样破坏性地改变历史。你可以在这里阅读:顺便说一句,如果你是git新手,我强烈推荐整本书。这是一个相对快速的阅读,它会让你对场景下发生的事情有一个很好的了解,包括图表等: