【发布时间】:2012-11-25 05:11:28
【问题描述】:
我将 Git 子树与我正在处理的几个项目一起使用,以便在它们之间共享一些基本代码。基础代码经常更新,升级可以发生在任何项目中,最终所有项目都会更新。
我遇到了一个问题,git 报告我的子树是最新的,但推送被拒绝。例如:
#! git subtree pull --prefix=public/shared project-shared master
From github.com:****
* branch master -> FETCH_HEAD
Already up-to-date.
如果我推送,我应该会收到一条消息说没有什么可以推送...对吗?正确的? :(
#! git subtree push --prefix=public/shared project-shared master
git push using: project-shared master
To git@github.com:***
! [rejected] 72a6157733c4e0bf22f72b443e4ad3be0bc555ce -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:***'
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 告诉你的事情: git pull ?
-
Git pull 与我的问题无关。但是,是的,git pull 给了我一条最新消息,因为原始仓库中没有任何新内容。
-
听起来你所在的分支在主 HEAD 所在的后面——例如,远程主 HEAD 所在的 ... -> A -> B -> C 的历史记录C,但您当前的分支位于 A(或未连接到 C 的 A 的某些后代)。我会看看我的 git 历史来确定。
-
我遇到了同样的问题。我一直在使用
--rejoin来加速子树推送。当我手动逐步完成子树推送时,运行subtree split --rejoin,拆分子树分支只有返回到上次重新加入的历史记录,而它通常包含整个子树历史记录。对我来说,这是非快进错误的直接原因。我仍然不确定为什么子树拆分会生成截断的历史记录。
标签: git git-subtree