将更新合并到我的子树时 Git 感到困惑 [英] Git confused when merging an update into my subtree

查看:25
本文介绍了将更新合并到我的子树时 Git 感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们之前在主存储库中使用了许多子模块,但为了提高项目的可维护性,我们启动了一个实验性分支,将它们全部替换为子树.

We previously used many submodules in our main repositories, but to increase the maintainability of our projects we started an experimental branch where we replaced them all with subtrees.

这很有效 - 但是现在当我尝试更新其中一个子树时,它错误地将更新合并到一个完全错误的目录中,该目录甚至不是子树.

This worked good - but now when I'm trying to update one of the subtrees it erroneously merges the update into a completely wrong directory that isn't even a subtree.

分支子树"包含实验分支的主存储库是:git://github.com/hugowetterberg/goodold_drupal.git

The main repository, where the branch "subtree" contains the experimental branch, is: git://github.com/hugowetterberg/goodold_drupal.git

要合并更新的存储库:git://github.com/voxpelli/drupal-oembed.git

合并:git merge -s subtree oembed/master

更新应该合并到的路径:sites/all/modules/oembed/

The path the updates should be merged into: sites/all/modules/oembed/

它们合并的路径:modules/aggregator/translations/

任何人都知道如何将更新放入子树或可能出现什么错误?

Anyone having an idea of how to get the updates into the subtrees or what the error can be?

推荐答案

不幸的是,这是git merge -s subtree"代码中的一个错误(或缺失的功能).它实际上猜测您要合并的子树.通常,这神奇地证明是正确的,但是如果您的子树包含大量更改(或者最初是空的,或者其他什么),那么它可能会失败.

Unfortunately this is a bug (or missing feature) in the "git merge -s subtree" code. It actually guesses the subtrees that you want to merge. Usually, this magically turns out to be correct, but if your subtree contains a lot of changes (or was originally empty, or whatever), then it can fail spectacularly.

解决它的最佳方法是:

  1. 按上述方式合并文件.

  1. Merge the files as you did above.

手动将所有生成的文件移动到它们应该去的地方.

Manually move all the resulting files to where they should have gone.

git commit -a --amend 以更正合并提交.

未来的合并可能会正常工作,除非此目录的变化量一直令人难以置信.

Future merges will probably work fine, unless this directory is constantly in unbelievable amounts of flux.

实验性的 "git subtree" 命令有一个 --prefix 应该让您覆盖它的参数,但不幸的是它目前不起作用(因为它需要解决git merge -s subtree"功能并且没有时间这样做).

The experimental "git subtree" command has a --prefix parameter that should let you override this, but unfortunately it doesn't work at the moment (since it requires working around "git merge -s subtree" features and there hasn't been time to do it).

无论如何,这应该是一种罕见的情况,即使将来合并同一项目也不需要解决方法.

Anyway, this should be a rare situation and the workaround won't be needed even for future merges of the same project.

这篇关于将更新合并到我的子树时 Git 感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆