I am versioning my config files with git. Now I need to move some of my config files to a different repository, to achieve a clean structure.
Is there a way I can keep the change log for a file if I move it to a different repository?
I would like to have all commits of repo A in repo B that touched file A/a if I move it to B/a. Ideally, if I afterwards move A/x to B/x, I would want to see B/a and B/x appear together in commits that touched both files in repository A. I would not expect to have any development step of A/a merged into any of the commits of B, I just want them to appear there afterwards.
Thank you, best regards
Best Answer
Assume you want to transfer the history of
filename.conf
from one source repository to another receiving repository. I think the strategy you want to follow is:filename.conf
.Definitely make backups of your repositories before you do this!
In the source repository, use filter-branch to rebuild the history removing everything except
filename.conf
.Then, in the receiving repository:
If you also need to move the path that
filename.conf
is in within the repository, you'll probably need to use the--subdirectory-filter
option ongit filter-branch
.