Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

So I mainly use Mercurial for my projects and I decided to sit down and learn all Git's shenanigans to discover if I'm in the right side (at least for me).

I'm learning that git uses namespaces for branches and I would like to know (in your experience) what is the point of namespaces?. In Mercurial I could just set the convention of naming branches like so:

<branch name> //for "origin" branches
<username>/<branch name> //for user branches

I imagine that there is more to it than just the name (aside from avoiding naming conflicts), but what do I get out of this seemingly more complicated (not necessarily bad) model?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Git doesn't "use" namespaces in the sense like they are required. It offers the completely optional ability for a user to use namespaces if they want them. You can use the exact same naming convention as you did in mercurial if you want, and I imagine that's what the vast majority of people do.

What namespaces buy you is the ability to combine multiple repositories into one, but be able to only show branches from the one virtual repository. Within the namespace, you can still name the branches using whatever method you prefer. Personally, I don't really see the benefit over just using multiple repositories, but obviously someone thought it might be useful sometimes.

Git has a ton of features, of which maybe 3-5% see daily usage by the typical developer. The trick to getting along with git, is for those features you don't want/like/understand, don't worry about them.

share|improve this answer

Never done something serious with mercurial, so I can miss something. I'm using namespaces in git branch naming pretty much, but I'm never inserting my name into the name of the branch.

For each task that are describe in task tracker we are creating a separate branch, with number of the ticket and short description of the bug. At this point there are no spaces yet:

  remotes/origin/275-test-new-urls
  remotes/origin/283-fullscreen
  remotes/origin/299-current-menu-item
  remotes/origin/301-users-api
  remotes/origin/306-range-window-resize
  remotes/origin/307-dropdown-init-onload

Then, say, you realize that some task need additional branches for experimenting. These branches are de-facto children to "main" task branch, i.e. after completion the should (if should at all) be merged to that very task. Here come namespaces:

 remotes/origin/283-fullscreen-buggy-animation   
 remotes/origin/283-fullscreen.refactor

I've seen that slash is also used for namespacing, but personally I prefer dots, since using slashes can produce some issues.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.