[英]Git moving files from one repo to another repo for history
I have a requirement to move few files from one repo to another repo with files commit history.我需要将少量文件从一个存储库移动到另一个具有文件提交历史记录的存储库。 Both repos are completely different structure.
两个回购都是完全不同的结构。
Repo 2 is belongs to another team. Repo 2 属于另一个团队。
Repo 1 - /folder1/subfolder1/text.txt回购 1 - /folder1/subfolder1/text.txt
TO到
Repo 2 - folder1/test.txt回购 2 - folder1/test.txt
Do we have a way to do this?.我们有办法做到这一点吗?
You can adapt the answer in How to move files from one git repo to another (not a clone), preserving history with eg您可以调整How to move files from one git repo to another (not a clone) 中的答案,使用 eg 保留历史记录
git filter-branch --subdirectory-filter sourcedir/subdir \
--index-filter '
git read-tree --empty
git ls-tree -r $GIT_COMMIT:sourcedir/subdir \
| sed s,\\t,\\tdestdir/, \
| git update-index --index-info
'
and add whatever other selection/munging instructions you want to the sed, like put "/.txt$/;d;"
并将您想要的任何其他选择/修改说明添加到 sed,例如 put
"/.txt$/;d;"
on the front of it so you drop everything but the.txt files, or whatever else you want to do to the path names.在它的前面,这样你就可以删除除了 .txt 文件之外的所有内容,或者你想对路径名做的任何其他事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.