Organizing git branches

branch, git

Solution

You can use a naming schemata like feature1/sub-brancha, feature2/sub-branchb and so on, the slash in the name is not a problem for git. However, the branches will still be handled as normal branches (but I wouldn't know how one could handle subbranches differently). The git branch command will list the branches of course with its full name and not the way it's in the example.

Interestingly, the naming schemata including slashes will create a directory hierarchy in .git/refs/heads/. Maybe that's useful for handling the subbranches with some low level commands?

Problem

I have a large-ish project that I'm working on which uses git as the VCS. At any given time I'm working on implementing a few features/bugfixes, etc. For any given feature/bug, It would be nice to create a hierarchy of branches -- e.g. ``` $ git branch feature1 sub-branch1 sub-branch2 sub-branch3 feature2 sub-brancha *sub-branchb #<--currently checked out sub-branchc bugfix1 sub-branch-foo $ git checkout sub-brancha $ git branch feature1 sub-branch1 sub-branch2 sub-branch3 feature2 *sub-brancha #<--currently checked out sub-branchb sub-branchc bugfix1 sub-branch-foo ``` Is it possible to do something like this, or do I need to adopt a more primitive naming scheme? EDIT To make it slightly more concrete what I'm looking for, if feature1 is a git branch, then in the example above, sub-branch1 would all have been created by `git checkout -b sub-branch1` from the `feature1` branch (which is branched from master). e.g.: ``` $ git checkout master $ git checkout -b feature1 $ git checkout -b testing $ git branch master feature1 *testing $ git checkout master $ git checkout -b feature2 $ git branch master feature1 testing *feature2 ``` Having git branch simply organize branches by where they came from (with a little extra indentation) is probably good enough for my purposes ... Although super bonus points if I can have: ``` $ git branch feature1 testing feature2 testing bugfix1 sub-branch-foo ``` With some way to manage the name-conflict between "feature1/testing" and "feature2/testing"

Original source