Skip to content

Instantly share code, notes, and snippets.

@cvakiitho
Last active July 26, 2016 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvakiitho/7167ff3098d7f28e90c2e79d653eda6f to your computer and use it in GitHub Desktop.
Save cvakiitho/7167ff3098d7f28e90c2e79d653eda6f to your computer and use it in GitHub Desktop.
Git extract directory 1 from repo A to repo B - including history only from that dir
git clone <git repository A url>
cd <git repository A directory>
git remote rm origin
git filter-branch --subdirectory-filter <directory 1> -- --all
// now you can move it to another dir if you need to - so it is in same structure as repo B
git clone <git repository B url>
cd <git repository B directory>
git remote add repo-A-branch <git repository A directory>
git pull repo-A-branch master
git remote rm repo-A-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment