Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>If you use '/' is branch names you can create path conflicts. I've seen it happen and it took me a day to debug and figure out. There is some code checking for path conflicts in the git source but it's not invoked via all code paths that create branches. I recommend against using slashes in branch names unless you know what you are doing.

Can you elaborate on this? What you said doesn't make much sense. If having a slash in the branch name creates path conflicts, that means slashes are treated specially, right? How exactly does someone 'know what they are doing' to be able to use them?



Yeah. For example:

  $ git branch fireos
  $ git branch fireos/feature-branch
  error: unable to create directory for .git/refs/heads/fireos/feature-branch
  fatal: Failed to lock ref for update: No such file or directory
This happens because creating 'fireos' branch stores the sha1 in file .git/refs/heads/fireos. But if you later want to create branch 'fireos/feature-branch', git needs to store the sha1 in .git/refs/heads/fireos/feature-branch. This is impossible because 'fireos' is a file and cannot be a directory. Path conflict.


It gets even uglier when you don't discover those conflicts until a pull or push.


It can be solved with a right branch naming policy. E.g. where I work we usually name branches like "wp/BTS-number/1" for first attempt to do the BTS-number task, "wp/BTS-number/2" when we somehow need to try another approach or rebase or squash history, "wp/BTS-number/3" for next attempt and so on.

But its a global policy so "wp" and "wp/BTS-number" will always be a folder, and conflicts should never happen.


I really like to use '/' to create folders. Git (X) has a nice GUI for this naming convention.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: