【问题标题】:git: how to merge commits from a remote to a different path?git:如何将来自远程的提交合并到不同的路径?
【发布时间】:2008-11-05 19:16:35
【问题描述】:

我有一个带有远程 foo 的 git 存储库。

foo 是一个网络应用程序,它直接在其根目录中包含一些文件和目录:

Rakefile
app
...
public
script

我的主要 git 存储库是一个更大的系统,其中包含这个 Web 应用程序。我想从 foo 中提取提交,但我需要将文件驻留在 web 目录中。所以他们应该变成web/appweb/public等等。

我不想将 foo 用作子模块。我想将 foo 合并到主存储库中,然后将其删除。

【问题讨论】:

    标签: git merge version-control


    【解决方案1】:
    【解决方案2】:

    子树合并的最新资源有:

    引用How to use the subtree merge strategy:

    在此示例中,假设您的存储库位于 /path/to/B(但如果您愿意,它也可以是 URL)。 您想将该存储库的主分支合并到当前分支中的 dir-B 子目录。

    这是您需要的命令序列:

    $ git remote add -f Bproject /path/to/B
    $ git merge -s ours --no-commit Bproject/master
    $ git read-tree --prefix=dir-B/ -u Bproject/master
    $ git commit -m "Merge B project as our subdirectory"
    
    $ git pull -s subtree Bproject master
    

    对于 cmets,另请参阅文章“Subtree merging and you”。

    【讨论】:

      【解决方案3】:

      如果您愿意接受它作为答案,这里是您的答案的社区 wiki 版本。


      这回答了我的问题:

      http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html

      【讨论】:

        猜你喜欢
        • 2015-07-15
        • 2017-03-05
        • 2014-07-17
        • 1970-01-01
        • 2020-05-09
        • 2015-06-07
        • 2013-04-08
        • 2012-06-07
        • 2019-08-02
        相关资源
        最近更新 更多