Skip to content

Instantly share code, notes, and snippets.

@tuliren
Created May 24, 2017 13:42
Show Gist options
  • Save tuliren/fa12ec139f8e63867f2e96f9a2ca2cd4 to your computer and use it in GitHub Desktop.
Save tuliren/fa12ec139f8e63867f2e96f9a2ca2cd4 to your computer and use it in GitHub Desktop.
Transfer files between two repositories with history
# http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/
mkdir /tmp/mergepatchs
cd ~/repo/org
export reposrc=myfile.c #or mydir
git format-patch -o /tmp/mergepatchs $(git log $reposrc|grep ^commit|tail -1|awk '{print $2}')^..HEAD $reposrc
cd ~/repo/dest
git am /tmp/mergepatchs/*.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment