Reputation: 37
we have one git repo in azure and all diff project codes resides in that. Now we want to move code of each project to its own repo and keep only one project in the existing main repo.
what would be the best way to do this work ? I am planning to clone the main repository and then keep one proj code in that and then publish to project wise repo. Is this the right approach? I have some 15 projects in existing main repo. DO I have to clone every time , remove other project code and publish for respective project?
Any other suggestions?
Right now ....
Main repo ( A,B,C,D,E,F)
we want ...
Main Repo (A) , Repo(B),Repo(C),Repo(D),Repo(E),Repo(F)
Upvotes: 1
Views: 445
Reputation: 40553
What you trying to do is to split repository with keeping hisotry (I guess). Since you use git this is the same like on any other hosts. Here you will find a way how to do this
git clone https://github.com/ao/your_repo.git
cd your_repo
git checkout your_branch_name
git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory your_current_branch_name
git remote set-url origin https://github.com/ao/your_new_sub_repo.git
git push -u origin your_current_branch_name
Or in one script:
git clone https://github.com/ao/your_repo.git
cd your_repo
git checkout your_branch_name
git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory your_current_branch_name
git remote set-url origin https://github.com/ao/your_new_sub_repo.git
git push -u origin your_current_branch_name
Upvotes: 1