将更新合并到我的子树时混淆了Git [英] Git confused when merging an update into my subtree

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

问题描述

我们之前在我们的主要存储库中使用了许多子模块,但为了增加项目的可维护性,我们开始了一个实验分支,在那里我们用子树替换了它们。



运行良好 - 但现在,当我试图更新其中一个子树时,它错误地将更新合并到完全错误的目录中,甚至不是子树。



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



合并资源库: git://github.com/voxpelli/drupal-oembed.git



合并操作: git merge -s subtree oembed / master

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

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



任何人都有想知道如何获取更新到子树或错误可能是什么?

解决方案

不幸的是,这是一个错误功能)在git merge -s subtree代码中。它实际上是猜测你想要合并的子树。通常情况下,这奇迹般地证明是正确的,但是如果你的子树包含很多变化(或者最初是空的,或者其他),那么它可能会失败。



解决这个问题的最佳方式是:


  1. 合并上述文件。


  2. 将所有生成的文件手动移至其应该 的位置。


  3. >未来的合并可能会正常工作,除非这个目录经常有令人难以置信的流量。



    实验 git subtree 命令有一个 - 前缀参数,可以让你覆盖这个参数,但不幸的是它没有现在并不奏效(因为它需要解决git merge -s subtree的功能,而且还没有时间去做)。



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


    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.

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

    The repository to merge in updates from: git://github.com/voxpelli/drupal-oembed.git

    Merging by doing: git merge -s subtree oembed/master

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

    The path they are merged into: modules/aggregator/translations/

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

    解决方案

    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.

    The best way to work around it is:

    1. Merge the files as you did above.

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

    3. git commit -a --amend to correct the merge commit.

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

    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天全站免登陆