Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoya/bb3c118fbbf7c71b832f to your computer and use it in GitHub Desktop.
Save smoya/bb3c118fbbf7c71b832f to your computer and use it in GitHub Desktop.
How to move files between repositories preserving history
  • Orig repo:
INITCOMMIT=$(git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$")
  • Dest repo:
git format-patch --git-dir=/repo_orig/.git --stdout $INITCOMMIT..HEAD | git am
@smoya
Copy link
Author

smoya commented Feb 22, 2016

In some cases, just adding the source repository as remote in the destination one, and merge the required branch is better than the previous method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment