Skip to content

Instantly share code, notes, and snippets.

@jcs
Last active December 19, 2016 18:19
Show Gist options
  • Save jcs/f2c2ba4f5f80e9df6055de8b4169fc0d to your computer and use it in GitHub Desktop.
Save jcs/f2c2ba4f5f80e9df6055de8b4169fc0d to your computer and use it in GitHub Desktop.
moving git commits from one tree to another
# moving git commits from one tree to another, preserving original git commit metadata like date/time
# (creating a new hash, of course)
# find current commits
git log jcs --author=jcs@jcs.org --no-merges --oneline --no-abbrev-commit --reverse | sed 's/ .*//' > commits
# in new git tree, for each $hash in $commits
git --git-dir=/path/to/old/tree/.git format-patch -k -1 --stdout <hash> | git am -3 -k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment