简体   繁体   中英

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 1 - /folder1/subfolder1/text.txt

TO

Repo 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

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;" on the front of it so you drop everything but the.txt files, or whatever else you want to do to the path names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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