This has taken a while for me to come up with an approach, and the approach I took probably isn’t the most efficient. In fact I am sure it isn’t.
But it worked and I thought it would be worth documenting it for the next time I want to do something like this.
So the issue was that I had two files (dicetastic.py and dicelib.py) that needed to be moved. These files has started out in their own (now deleted) Dicetastic repository and then merged into my utilities repository. Now I wanted to move them to silliness, while retaining the git history.
The approach I eventually took was to format a set of patches from the original repositor(y|ies) and then merge them into the new.
So first I created a folder called rollout:
Then I formatted the patches I needed from the utilities folder:
cd utilities git format-patch -o ../rollout --root dice*
This created three patches in the rollout folder. Unfortunately this wasn’t quite what I wanted as none of the history from before I started mucking about with this.
So I went back and formatted the patches from the Dicetastic folder:
cd ../Dicetastic git format-patch -o ../rollout --root dice*
And I will note here that I should have done this for everything, not the dice* files, in order to include the changes to the README. Oh well.
So now I have a collection of patches in the rollout folder, which I could use to rebuild the history in the silliness folder.
If I had done this properly, I should have been able to use:
git am ~/Code/patches/*.patch
Unfortunately, because I had created two sets of patches in the same folder I had a slightly scary numbering issue. And because there were only seven patches I decided to apply them individually so that I could see what I was doing.
But it worked and all that was left was for me to commit the changes and push them and both the files are in the right place, along with their full history.