Git子树推送失败,就像过期一样

Git子树推送失败,就像过期一样,git,git-subtree,Git,Git Subtree,我看到过一些类似的问题,但上面列出的解决方案似乎对我们不起作用 我们有一份包含许多不同子树的回购协议。对于其中一些应用程序,git子树推送工作正常,而对于其他应用程序,它会失败,原因如下: hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint

我看到过一些类似的问题,但上面列出的解决方案似乎对我们不起作用

我们有一份包含许多不同子树的回购协议。对于其中一些应用程序,git子树推送工作正常,而对于其他应用程序,它会失败,原因如下:

hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
我们将重点放在其中一个断开的子树上,以确定问题

在我们的主回购协议中,我们有一个分支(我们称之为BranchA),子树以前是从该分支中拆分出来的(
git子树拆分
,然后是拆分分支的
git push
)。然后,远程BranchA被重新引入为:

git subtree add --prefix=/path/to/subtree SubtreeRemoteName BranchA
子树的远程存储库目前只包含一个commit(017f3783),我们给了它相同的BranchA名称

我可以看到布兰卡的历史记录中添加了拆分:

$ git show df968c
commit df968c95dd2cd3f2ea1f4e059dfd19b1661d275d
Merge: 6f86ff21 017f3783
Author: Me
Date:   Wed Nov 29 11:50:56 2017 -0600

    Add 'path/to/subtree' from commit '017f3783af9260c0de29a85916bc5f4776c186c2'

    git-subtree-dir: path/to/subtree
    git-subtree-mainline: 6f86ff21afbed1a0da60f4019ae20c43f28ee5db
    git-subtree-split: 017f3783af9260c0de29a85916bc5f4776c186c2
自最初添加子树以来,各种内容已提交到主存储库的BranchA中,我们现在正在尝试:

git subtree push --prefix=path/to/subtree SubtreeRemoteName BranchA
返回上述错误

我们尝试过的事情:

git subtree pull --prefix/path/to/subtree SubtreeRemoteName BranchA
返回:

From https://ourgitserver/path/to/subtree/repo
 * branch              BranchA      -> FETCH_HEAD
 + 50a42087...017f3783 BranchA      -> SubtreeRemoteName/BranchA (forced update)
Already up-to-date.
* BranchA
我确实发现那里的“强制更新”评论可能很有趣,但鉴于提交散列似乎仍在排列,我不知道这是否重要

此外,运行:

git branch --contains 017f3783
返回:

From https://ourgitserver/path/to/subtree/repo
 * branch              BranchA      -> FETCH_HEAD
 + 50a42087...017f3783 BranchA      -> SubtreeRemoteName/BranchA (forced update)
Already up-to-date.
* BranchA
确认必要的提交实际上已经在BranchA

一个问题()建议将子树push分解为单独的split/push命令,并将force标志添加到push中。虽然这确实有效(在推送成功的意义上),但它也重写了现有的提交,这将破坏我们的其他回购协议,这些协议也将此作为子树

如果我在拆分此分支之前立即从提交中签出一个新分支,并运行子树的新拆分(基本上重复最初完成的拆分):

正如预期的那样,创建的TempBranch将显示相同的散列(017f3783),然后将其合并,如前面的合并提交中所示。有趣的是,如果我尝试删除TempBranch,它的行为就像没有合并一样:

$ git branch -d TempBranch
error: The branch 'TempBranch' is not fully merged.
If you are sure you want to delete it, run 'git branch -D TempBranch'.
它需要强制删除(-D标志)才能实际删除它

如果我从当前BranchA运行相同的剥离,我会得到一个没有父级的提交:

$ git show bcc9f
commit bcc9f244f855d99ee1547ee309ba1606ed7a35fc
Author: Me
commit bcc9f244f855d99ee1547ee309ba1606ed7a35fc
Author: Me
Date:   Wed Nov 29 15:49:50 2017 -0600

    Commit text.
运行拆分,但传递“转到”标志:

只创建没有父级的相同bcc9f244提交

有什么建议吗