There are a variety of characters that are allowed in a branch (or other ref) name, including the slash. In fact, a branch foo
is really just a reference of the form refs/heads/foo
. As such, adding more slashes is totally possible.
The reason people often use them is to roughly categorize their branches. For example, at work we share a single repository for our projects instead of using forks, so some developers prefer to create branches named username/branch
to avoid conflicting with other users' branches. In addition, some projects prefer to categorize refs into groups like feature/*
, bugfix/*
, or hotfix/*
.
The documentation for git check-ref-format
outlines the valid formats. Because references are stored in the file system, there are some practical limitations to what can be in a ref. For example, you cannot have both branches foo
(ref refs/heads/foo
) and foo/bar
(ref refs/heads/foo/bar
) because in the former case foo
would need to be a file and in the latter case it would need to be a directory. Also, if your file system is case insensitive or restricts certain byte sequences, that will often be reflected in whether you can store branches differing in case or using the byte sequences on your system.
There is a plan for a ref backend called reftable that doesn't suffer from these limitations, but it has not yet been implemented in Git.