Skip to content

Instantly share code, notes, and snippets.

@kmilligan
kmilligan / gist:4657831
Created January 28, 2013 18:24
Getting contents from a subdirectory of repo A into a different subdirectory of repo B while maintaining history
First, make repoA contain only the files from the subdirectory you care about. To do this, we're going to first create a new working branch, and then use the filter-branch function of git.
cd ~/repoA
git branch -b informative_branch_name
git filter-branch --subdirectory-filter branch/you/want/with/trailing/slash/ -- --all
If you ls, you'll see that the repo contains only the files from the desired subdirectory. It would be a poor decision to push at this time.
Next, visit repoB, and add repoA as a remote. After that, check out the branch you just created (informative_branch_name)