Wednesday, May 1, 2013

How to split repository into two repositories


Source of wisdom.

We have infra repository that is have folder git_tool that is going to be new repository now.

State of repository "infra" before split:
jenkins_checks
svn2git
git_tools
build-release.sh              

Task: move "git_tools" to separate repository "infra_new".

Steps:
1. Create new repo for "git_tools" only
$ git clone  git@git.yourserver.com:infra
$ cd infra/
$ git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch jenkins_checks/* sb-svn2git/* build-release.sh eclipse-compiler-warnings.epf ' HEAD
$ gitk --all
$ git remote add origin https://git@git.yourserver.org/infra_new.git
$ git push -u origin --all

2. Remove all history remnants from old "infra" repo:

$ git clone  git@git.yourserver.com:infra
$ cd infra/
$ git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch git_tools/*' HEAD
$ gitk --all
$ git push -u origin --all --force

No comments:

Post a Comment