Reputation: 101
I have a Git repo that has subfolders like:
- myproject
+ folder1
+ folder2
+ folder3
How can I push a subfolder (i.e. folder1) to another Git repo? I thought submodule was the right approach, but I don't think I'm using it correctly or if it applies here. The way I tried using submodule was:
git submodule add git@urlofnewrepo folder1
But that results in an error as:
'folder1' already exists in the index
Upvotes: 1
Views: 120
Reputation: 101
R0MANARMY pointed me to http://blogs.atlassian.com/2014/04/tear-apart-repository-git-way/ which basically accomplishes what I want to do. The workflow is:
git clone remote_repo_url new_repo_name
git filter-branch --subdirectory-filter folder_to_filter
So in my case, it was:
git clone remote_repo_url new_repo_name
git filter-branch --subdirectory-filter folder1
This resulted in the folder "new_repo_name" only containing files from "folder1".
Upvotes: 1
Reputation: 21837
Try --force
key, like:
git submodule add --force git@urlofnewrepo folder1
Upvotes: 0