简体   繁体   English

Git 将文件从一个存储库移动到另一个存储库以获取历史记录

[英]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.

相关问题 将资产从一个仓库移到另一个仓库,git提交历史? - Moving Assets from one Repo to another, git commit history? 将子文件夹从一个 git repo 移动到另一个保留历史记录 - Moving subfolder from one git repo to another preserving history 将一个 git 存储库复制到另一个具有历史记录的存储库 - Copying one git repo to another repo with history 从一个仓库迁移到另一个仓库时保存提交历史 - Preserving commit history when moving from one repo to another 将目录从一个Git存储库迁移到具有所有历史记录的另一个目录 - Migrate a directory from one Git repo to another with ALL history 如何将特定文件从一个git存储库复制到另一个,从而保留历史记录 - How to copy specific files from one git repo to another, preserving history 如何将一些文件从一个 git 存储库移动到另一个(不是克隆),保留历史记录 - How to move some files from one git repo to another (not a clone), preserving history 将多个文件和目录从一个git repo复制到另一个,同时保留其原始历史记录 - Copy multiple files and dirs from one git repo to another while keeping their original history 如何将一个 repo 移动到另一个 repo 文件夹并保留 git 历史记录? - How to move one repo to another repo folder and keep git history? Git-将文件移动到另一个存储库并保留源 - Git - moving files to another repo and preserving source
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM