Do you have monstrous files with lots of classes in your repository, but you are afraid to split them because you don't want to lose git change history?
This is a PowerShell script that allows to extracts a line range from the specified file into another file, preserving git history for both the original file and the extracted bit.
splitwithhistory -s 20 -e 70 -p 'AC-82445' -o 'ManyClasses.cs' -t 'SingleClass.cs'
-s
or-start
- the number of the first line (inclusive) to be extracted to a separate file. Required.-e
or-end
- the number of the last line (inclusive) to be extracted to a separate file. Required.-p
or-commitPrefix
- optional prefix of the automatic commits that will be made in the git repository.-o
- the source file name, from which the specified line range will be extracted. Required.-t
- the target file name, to which the specified part of the source file will be extracted. Required.-tr
- optional new name for the source file.-b1
- optional name of the first temporary branch that will be used to create a necessary merge conflict. By default, equalssplitwithhistorytemporaryhistorybranch1
.-b2
- optional name of the first temporary branch that will be used to create a necessary merge conflict. By default, equalssplitwithhistorytemporaryhistorybranch2
.
The branches specified by the -b1
and -b2
parameters will be created and deleted automatically.