Monday, January 18, 2021

Git: Moving files to a new repository while preserving history

> git --version
git version 2.18.0
This method did not work for me: Move files from one repository to another, preserving git history
But this one did the trick: Moving Files and Directories to a New Repository in Git

Here is the list of commands used in order to extract the contents of the perl/ directory from the connectmv repo. into the ss-sms-vas repo.:
> mkdir cloneA
> cd cloneA/
> git clone git@github.com:<MY_TEAM>/connectmv.git
> cd connectmv/
> git subtree split --prefix perl/ --branch my-subtree
> git checkout my-subtree
> git remote add repoA git@github.com::<MY_TEAM>/ss-sms-vas.git
> git pull repoA main --allow-unrelated-histories

> git push -u repoA my-subtree:main
> cd ../../
> rm -rf cloneA/

> cd ss-sms-vas/
> git pull
> git lol lib/MBQT/mod_perl/AbstractVas.pm 
* 72be224f (Thu Jan 7 18:32:47 2021 Jerome G) PLTBUGS-8700: exploded USSD CDR per process
* 680a9ff2 (Thu Jan 7 13:51:45 2021 Jerome G) PLTBUGS-8700: removed unlock
...