Last Updated: June 19, 2019
·
3.675K
· craigmarvelley

Extracting Symfony2 bundles using 'git subtree split'

I've been working on a Symfony2 app, and we decided to extract some bundles so they could be used in other projects. I wanted to keep commit history (we're using Git) and found the new subtree functionality to be just the ticket:

First, add a Git remote to the Symfony2 project Git repository. This is the repository which will contain the separated bundle:

git remote add my-bundle-repo git@github.com:yourname/my-bundle-repo.git

Then use git subtree to create a new branch (called split-bundle) which contains only the code underneath the given prefix, and history relating to those files:

git subtree split --prefix=src/path/to/my/Symfony2Bundle -b split-bundle

Once that's done, push the new branch to your bundle remote, and you're done!

git push my-bundle-repo split-bundle:master

1 Response
Add your response