Skip to content

Instantly share code, notes, and snippets.

@brabect1
Last active January 1, 2024 19:40
Show Gist options
  • Save brabect1/d358a8d52df7d16775942914df768844 to your computer and use it in GitHub Desktop.
Save brabect1/d358a8d52df7d16775942914df768844 to your computer and use it in GitHub Desktop.
Shows how to export and import Git repository. #git #export #import #patch

Transferring Git Commit History

Exporting the complete repo history in a form of patch files (based on https://randombrainworks.com/2017/02/17/git-moving-commits-between-repositories/):

cd path/to/orig/repo
git format-patch --output-directory ../patches $(git rev-list --max-parents=0 HEAD) $(git rev-list HEAD -1)

Create a 2nd repo (here for testing purposes):

cd path/to/new/repo
git init

Import into the 2nd repository:

cd path/to/new/repo
git am path/to/orig/patches/*.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment