Reputation: 7337
I want to have a three branch setup on my repository:
"Develop" will be where on-going development is taking place. In this develop branch, I would like to have my unit tests, but I want to keep the unit tests out of the other two branches. So, ideally, I want the "tests" folder within the develop branch to never be merged into any other branch. Is this possible?
Upvotes: 0
Views: 168
Reputation: 150665
It is possible by having a different branch that has the tests, and a production branch that has just the code you want to use.
I do this myself with Cocoa Classes where I want to be able to share the class, but also to share an example project that shows how to use the class, but I don't want all the extra code when I'm using it as a submodule.
The trick is to do all your work with tests and examples in the main branch, or development branches that merge with the main branch. And then create another branch (in my case I call this the production
branch), where you do a git rm
on all the subsidiarry code.
Now, the trick is to not do any development on this production branch. Only work on the main branch and periodically rebase (or merge if you like) merge the master branch into the production branch. Git "remembers" that the subsidiary code was removed, and apart from a little tidying up you're left with a branch that only has the code that you want to use/share, but the tests/example code still exists in the repository if you are anyone else cares to work with it.
You can see an example of this on GitHub with my JCSSheetController class.
Upvotes: 2