Phriction Projects Wikis C4science Split a repository into multiple repositories History Version 6 vs 9
Version 6 vs 9
Version 6 vs 9
Content Changes
Content Changes
Your initial repository structure looks the schematic below. We want to split dir1, dir2 and dir3 into separate repositories.
```
myrepo
├── dir1
│ ├── myfile1
│ ├── myfile2
│ └── myfile3
├── dir2
│ ├── myfile1
│ ├── myfile2
│ ├── myfile3
│ └── myfile4
└── dir3
└── myfile
```
## GIT
You can use `git subtree` to extract only one part of your repository, including its history. Here's a complete example on how to create new repositories from one repository with multiple directories.
On your computer, create empty repositories
```
mkdir /tmp/repo-dir{1,2,3}
cd /tmp/repo-dir1; git init --bare
cd /tmp/repo-dir2; git init --bare
cd /tmp/repo-dir3; git init --bare
```
Go to the original repository and create one branch per directory you want to split
```
cd myrepo
git subtree split --prefix=dir1 -b dir1-branch
git subtree split --prefix=dir2 -b dir2-branch
git subtree split --prefix=dir3 -b dir3-branch
```
Push the branch of the original repository to the new local repositories on a new master branch
```
git push /tmp/repo-dir1 dir1-branch:master
git push /tmp/repo-dir2 dir2-branch:master
git push /tmp/repo-dir3 dir3-branch:master
```
Create the repositories on c4science, set the remote on your local repository for each new repository and push the new repositories to c4science
```
cd /tmp/repo-dir1; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir2; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir3; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
```
Deactivate the original repository on c4science and potentially [[/maniphest/task/edit/form/8/ | ask an administrator]] to remove the repository.
Enjoy your new tinier repositories :-)
## SVN
COMING SOON
Your initial repository structure looks the schematic below. We want to split dir1, dir2 and dir3 into separate repositories.
```
myrepo
├── dir1
│ ├── myfile1
│ ├── myfile2
│ └── myfile3
├── dir2
│ ├── myfile1
│ ├── myfile2
│ ├── myfile3
│ └── myfile4
└── dir3
└── myfile
```
## GIT
You can use `git subtree` to extract only one part of your repository, including its history. Here's a complete example on how to create new repositories from one repository with multiple directories.
On your computer, create empty repositories
```
mkdir /tmp/repo-dir{1,2,3}
cd /tmp/repo-dir1; git init --bare
cd /tmp/repo-dir2; git init --bare
cd /tmp/repo-dir3; git init --bare
```
Go to the original repository and create one branch per directory you want to split
```
cd myrepo
git subtree split --prefix=dir1 -b dir1-branch
git subtree split --prefix=dir2 -b dir2-branch
git subtree split --prefix=dir3 -b dir3-branch
```
Push the branch of the original repository to the new local repositories on a new master branch
```
git push /tmp/repo-dir1 dir1-branch:master
git push /tmp/repo-dir2 dir2-branch:master
git push /tmp/repo-dir3 dir3-branch:master
```
[[ c4science/simplerepo | Create the repositories ]] on c4science, set the remote on your local repository with each new repository and push the new repositories to c4science
```
cd /tmp/repo-dir1; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir2; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir3; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
```
Deactivate the original repository on c4science and potentially [[/maniphest/task/edit/form/8/ | ask an administrator]] to remove the repository.
You can now remove the temporary bare repositories (/tmp/repo-dir1, /tmp/repo-dir2, /tmp/repo-dir3) and clone them from c4science.
Enjoy your new tinier repositories :-)
## SVN
You have two solutions,
1. Contact the administrator and ask for a specific split solution (which directories goes where) and we will do it for you
2. Migrate your repository to GIT and split it yourself at the same time
Here's how to migrate your repository from SVN to GIT,
* Get a specific directory (dir1, ...) of your SVN repository and check it out as GIT:
```
cd /tmp
git svn clone svn+ssh://git@c4science.ch/diffusion/XXX/dir1
```
* [[ c4science/simplerepo | Create a new repository ]] on c4science to host this sub-repository `dir1`, add the remote and push
```
cd dir1
git remote add origin ssh://git@c4science.ch/diffusion/YYYY/
git push -u origin master
```
And voila, ask the c4science admin to remove your old SVN repository
Your initial repository structure looks the schematic below. We want to split dir1, dir2 and dir3 into separate repositories.
```
myrepo
├── dir1
│ ├── myfile1
│ ├── myfile2
│ └── myfile3
├── dir2
│ ├── myfile1
│ ├── myfile2
│ ├── myfile3
│ └── myfile4
└── dir3
└── myfile
```
## GIT
You can use `git subtree` to extract only one part of your repository, including its history. Here's a complete example on how to create new repositories from one repository with multiple directories.
On your computer, create empty repositories
```
mkdir /tmp/repo-dir{1,2,3}
cd /tmp/repo-dir1; git init --bare
cd /tmp/repo-dir2; git init --bare
cd /tmp/repo-dir3; git init --bare
```
Go to the original repository and create one branch per directory you want to split
```
cd myrepo
git subtree split --prefix=dir1 -b dir1-branch
git subtree split --prefix=dir2 -b dir2-branch
git subtree split --prefix=dir3 -b dir3-branch
```
Push the branch of the original repository to the new local repositories on a new master branch
```
git push /tmp/repo-dir1 dir1-branch:master
git push /tmp/repo-dir2 dir2-branch:master
git push /tmp/repo-dir3 dir3-branch:master
```
[[ c4science/simplerepo | Create the repositories ]] on c4science, set the remote on your local repository forwith each new repository and push the new repositories to c4science
```
cd /tmp/repo-dir1; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir2; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
cd /tmp/repo-dir3; git remote add origin ssh://git@c4science.ch/diffusion/NNNN/; git push -u origin master
```
Deactivate the original repository on c4science and potentially [[/maniphest/task/edit/form/8/ | ask an administrator]] to remove the repository.
You can now remove the temporary bare repositories (/tmp/repo-dir1, /tmp/repo-dir2, /tmp/repo-dir3) and clone them from c4science.
Enjoy your new tinier repositories :-)
## SVN
You have two solutions,
1. Contact the administrator and ask for a specific split solution (which directories goes where) and we will do it for you
2. Migrate your repository to GIT and split it yourself at the same time
Here's how to migrate your repository from SVN to GIT,
* Get a specific directory (dir1, ...) of your SVN repository and check it out as GIT:
```
cd /tmp
git svn clone svn+ssh://git@c4science.ch/diffusion/XXX/dir1
```
* [[ c4science/simplerepo | Create a new repository ]] on c4science to host this sub-repository `dir1`, add the remote and push
```
cd dir1
git remote add origin ssh://git@c4science.ch/diffusion/YYYY/
git push -u origin master
```
COMING SOONAnd voila, ask the c4science admin to remove your old SVN repository
c4science · Help