Andrew D
Andrew D

Reputation: 37

Segregate repos for different project from main repo in Azure

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

Answers (1)

Krzysztof Madej
Krzysztof Madej

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

  1. Clone your existing repo to a temp location
git clone https://github.com/ao/your_repo.git
cd your_repo
  1. Checkout the branch where the subdirectory is
git checkout your_branch_name
  1. Run the Git Filter-Branch Command
git filter-branch --prune-empty --subdirectory-filter relative/path/to/subdirectory your_current_branch_name
  1. Update your new Git Remote
git remote set-url origin https://github.com/ao/your_new_sub_repo.git
  1. Push your changes
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

Related Questions