DEV Community

Discussion on: Git Concepts I Wish I Knew Years Ago

Collapse
 
sqlrob profile image
Robert Myers

Just a warning on branches that I've learned the hard way.

You have branch foo/bar. Do NOT EVER create a branch foo.

This may have changed since it's an internal git detail, but in the first case, foo would be a directory. In the second, foo is a file. Something can not be both a file and directory at the same time, so you're asking for a world of hurt.

Collapse
 
g_abud profile image
Gabriel Abud

Interesting, I've never run into this situation but it makes sense. Will keep this in mind.

Collapse
 
bloodgain profile image
Cliff • Edited

I would recommend foo-bar style naming instead. Tab completion works just as well, and there's no unnecessary directory structure created in refs. It also completely avoids this error.

EDIT: I found one downside to this. If you like to set all your primary branches to be the default output for git show-branch and not show topic branches, you have to use subdirectories for your topic branches. I don't use show-branch much at this time, but this could matter to someone who does. Reference: git-scm.com/docs/git-show-branch#_...