Created
August 11, 2022 11:04
-
-
Save eirenik0/3be5bfd6b6b63039d53ac2f99664dde5 to your computer and use it in GitHub Desktop.
Keep git history when splitting a file https://stackoverflow.com/questions/3887736/keep-git-history-when-splitting-a-file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [[ $# -ne 2 ]] ; then | |
echo "Usage: git-split.sh original copy" | |
exit 0 | |
fi | |
git mv $1 $2 | |
git commit -n -m "Split history $1 to $2" | |
REV=`git rev-parse HEAD` | |
git reset --hard HEAD^ | |
git mv $1 temp | |
git commit -n -m "Split history $1 to $2" | |
git merge $REV | |
git commit -a -n -m "Split history $1 to $2" | |
git mv temp $1 | |
git commit -n -m "Split history $1 to $2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment