Yesterday I had to move a few files from a Git repository A to repository B while working on a client’s project. Today I had to do it again on another project. Again I had to think about the sequence of commands I had used. For this reason I’m posting this here.
Prepare repository A (the source)
1 2 3 4 5 6 7 8 9 10
In line #1 we clone the source repository so we can’t break the original one, we also remove the remote in line #4 so no links back to the source repository exist. Next using the filter-branch command we filter out everything but the directory we want to keep. Pull files to new repository
1 2 3 4 5