繁体   English   中英

如何将git存储库移至文件夹并将另一个存储库合并为原始库?

[英]How to move git repository to a folder and merge another repository into original?

我有一个httpdocs文件夹的git存储库。 我让某人为一个模块编写了一些代码,该模块位于httpdocs的几个子目录中。 这被存储在单独的存储库中。 他还编写了一些位于httpdocs之上的代码。 我想将所有内容合并到一个存储库中。

回购1:(httpdocs)

/

回购2 :(根)

/src
/vendor
/httpdocs/sites/all/modules/custom_module

我如何将Repo 1上移至一个级别并将所有内容放入一个名为httpdocs的文件夹中,然后在保持历史记录的情况下全部与Repo 2合并?

这就是git merge命令的子树策略选项的作用。

存储库2(根目录之一)应该是您进行合并的位置。 您将仓库1添加为远程git merge -Xsubtree=/httpdocs/sites/all/modules/custom_module httpdocs/master并按照git merge -Xsubtree=/httpdocs/sites/all/modules/custom_module httpdocs/master的行进行git merge -Xsubtree=/httpdocs/sites/all/modules/custom_module httpdocs/master

不要害怕尝试。 如果您第一次遇到错误,只需重设为起点并重新开始。 直到将结果推回中央存储库之前,这都没有关系。

请注意,如果您稍后在Repo 1中进行了一些更新,则git应该能够确定重新合并本身的路径,因此git merge -ssubtree httpdocs/master应该可以工作。 但是第一次您必须告诉它放置子模块的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM