Skip to content

Instantly share code, notes, and snippets.

@jasonkeene
Last active June 15, 2018 14:41
Show Gist options
  • Save jasonkeene/eb401c68af7612299a15 to your computer and use it in GitHub Desktop.
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.
# 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