Created
January 24, 2021 04:54
-
-
Save jgwill/c9ea536f4779bdbf108c913359e9fb2a to your computer and use it in GitHub Desktop.
Duplicate GIT branching - branch a file to a new one and keep the original using the same data in the repo so they wont be stored twice
This file contains 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/bash | |
dupsrc=$1 | |
newname=$2 | |
branchname="dup-$dupsrc-$newname" | |
git checkout -b $branchname | |
git mv "$dupsrc" "$newname" | |
git commit . -m "dup:mv $dupsrc $newname" | |
git checkout HEAD~ "$dupsrc" | |
git commit . -m "restore:$dupsrc" | |
git checkout - | |
git merge --no-ff $branchname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment