Split a single file into multiple files under a directory name based on the original.
Maintain git history.
Create a file names.txt
that contains one line for each of the files that are the targets of the split.
- Ensure there is a blank line at the end of file or the last entry will be ignored.
- An
index
file is not automatically created, you will need to explicitly list it.
This is useful to retain. The merge commits produced by this script will not survive rebase and need to be recreated, meaning you will need to run the same command again in future.
git-split.sh some/file/path/name.ext "my commit message" < names.txt
The first argument is the file to split.
The second argument is the commit message.
The stdin stream is expected to be the names of the files that you wish to split into.
Maintain a copy of your original branch.
- Reset your branch to the point preceding where the script commits begin.
- Rerun the script. This is where it is important to retain your
names.txt
. - Cherry-pick any remaining commits from the original branch.