Reputation: 683
I have two git repositories: repo1 and repo2. repo1 contains folders "dir_a", "dir_b" and other. How I can transfer all files including git history from dir_a and dir_b of repo1 to repo2?
I've found some helpful article for such task: http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history. However, it is not fully suitable for me because I need to transfer 2 directories.
Upvotes: 0
Views: 775
Reputation: 141956
How I can transfer all files including git history from dir_a and dir_b of repo1 to repo2?
You can use git filter-branch
and or git subtree split
filter-branch
# Filter the master branch to your directory and remove empty commits
git filter-branch --prune-empty --subdirectory-filter YOUR_FOLDER_NAME filter_from_branch
This will checkout all your desired files from the given folder to the current directory
subtree split
git subtree
git-subtree
-Merge
subtrees together orsplit
repository into subtrees
git subtree split -P <name-of-folder> -b <name-of-new-branch>
Upvotes: 1