首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何导入另一个git存储库作为子目录,并将其所有历史记录分组到提交日志的开头?

如何导入另一个git存储库作为子目录,并将其所有历史记录分组到提交日志的开头?
EN

Stack Overflow用户
提问于 2016-05-25 05:30:57
回答 2查看 365关注 0票数 3

给定包含文件的git存储库A:

代码语言:javascript
复制
A/a.1.txt

并提交历史记录:

代码语言:javascript
复制
A3333333333
A2222222222
A1111111111

和包含文件的git存储库B:

代码语言:javascript
复制
B/a.1.txt

并提交历史记录

代码语言:javascript
复制
B3333333333
B2222222222
B1111111111

我希望将存储库B作为子目录导入到存储库A中,并将其所有历史记录分组到A的历史记录之后,以便它具有文件

代码语言:javascript
复制
A/a.1.txt
A/B/a.1.txt

并提交历史记录:

代码语言:javascript
复制
B3333333333
B2222222222
B1111111111
A3333333333
A2222222222
A1111111111
EN

回答 2

Stack Overflow用户

发布于 2016-05-25 06:18:55

如下所示:

代码语言:javascript
复制
# register the remote of the other repo
git remote add -f other url-to-repo

# merge the content from `other`
git merge -s ours --no-commit other/master

# read the content under the directory PREFIX
#git read-tree --prefix=somedir -u other/master
git read-tree --prefix=A -u other/master

# commit the merge
git commit -m "subtree merge"

提交历史记录不会像您要求的那样是100%,因为另一个分支将被合并,所以在最后会有一个合并提交,历史记录看起来更像这样:

代码语言:javascript
复制
*   938762e (HEAD -> append) subtree merge
|\
| * B3333333333
| * B2222222222
| * B1111111111
* A3333333333
* A2222222222
* A1111111111
票数 2
EN

Stack Overflow用户

发布于 2016-05-25 06:15:03

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37424247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档