Last active
June 15, 2018 14:41
-
-
Save jasonkeene/eb401c68af7612299a15 to your computer and use it in GitHub Desktop.
Moves commits from one repo to another preserving commit messages and author date.
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
# Usage: | |
# cd ~/my_old_repo | |
# git-move HEAD ~/my_new_repo | |
function git-move { | |
src=$(pwd) | |
commit=$1 | |
dest=$2 | |
git rev-list $commit --reverse | | |
while read hash; do | |
date=$(git log -1 $hash --pretty=format:%ad) | |
git archive $hash | | |
(cd $dest && | |
tar -xpf - && | |
git add --all && | |
cat <(cd $src && git log -1 $hash --pretty=format:%s) | | |
git commit --date="$date" -F -) | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment