Organizing git branches

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?


Branches in Git are in fact symbolic refs to a key in Git's object store. To quote the documentation ("What is a branch"):

When we need to be precise, we will use the word "branch" to mean a line of development, and "branch head" (or just "head") to mean a reference to the most recent commit on a branch. In the example above, the branch head named "A" is a pointer to one particular commit, but we refer to the line of three commits leading up to that point as all being part of "branch A".

Git manages only a list of references which are stored in files under .git/refs. Those references are simply not designed as a tree-like structure.

I recommend to use a branch naming scheme that conveys the hierarchy.

Another possibility is to write an extension that handles the branch tree for you.

Tags:

Branch

Git