Skip to content

Instantly share code, notes, and snippets.

@vrkansagara
Forked from ralphschindler/workflow.md
Created February 22, 2016 07:07
Show Gist options
  • Save vrkansagara/7e80a8983c43eadc0931 to your computer and use it in GitHub Desktop.
Save vrkansagara/7e80a8983c43eadc0931 to your computer and use it in GitHub Desktop.
Breaking directories out of a repository into their own repository
git clone ./zf2 ZendServiceAmazon-library;
git clone ./zf2 ZendServiceAmazon-tests;
git init ZendServiceAmazon;
cd ZendServiceAmazon-library;
git filter-branch --subdirectory-filter library/Zend/Service/Amazon -- --all;
git filter-branch --index-filter 'git ls-files -s | sed "s--library/ZendService/Amazon/-g" | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
cd ../;


cd ZendServiceAmazon-tests;
git filter-branch --subdirectory-filter tests/Zend/Service/Amazon -- --all;
git filter-branch --index-filter 'git ls-files -s | sed 's- -   tests/ZendService/Amazon/-g' | GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
cd ../;


cd ZendServiceAmazon;
touch README.md;
git add README.md;
git commit -m "Initial Commit of README.md";
git remote add -f library ../ZendServiceAmazon-library;
git remote add -f tests ../ZendServiceAmazon-tests;
git merge -s ours --no-commit library/master
git read-tree -u library/master
git commit -m "Merging in ./library for ZendService\Amazon";
git merge -s ours --no-commit tests/master
git read-tree --prefix=tests/ZendService/Amazon -u tests/master
git commit -m "Merging in ./tests for ZendService\Amazon";
git remote add origin https://github.com/zendframework/ZendServiceAmazon.git
git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment