2

Given that there's no wide agreement on the semantics of master, we're considering having no branch named master at all on our origin server.

What are the consequences of that in terms of defaults that are built in to the standard git command line client? How does it treat a branch named master differently from other branches -- both locally and on the remote?

Matt McHenry
  • 20,009
  • 8
  • 65
  • 64
  • As far as I know, other than actually defaulting a new repository to having a branch named master that is also "checked out" (as far as one can consider it being checked out in an empty repository), there is no special handling of this branch name at all. – Lasse V. Karlsen Jun 11 '18 at 19:48
  • 1
    See also https://stackoverflow.com/a/25449034/6309 – VonC Jun 11 '18 at 20:18

2 Answers2

3

From my survey of the codebase and my experience with repositories that don't have a master branch, I'd say you're in the clear.

At worst, the are a couple of edge cases where not being explicit will cause a command failure instead of falling back to a master branch.


  • git clone sets up a master branch by default when no remote refs are found and the --bare flag wasn't specified (builtin/clone.c)
  • git fast export with the --anonymize flag leaves master alone, since it's a well-known default and doesn't communicate anything (built-in/fast-export.c)
  • merge commit messages are customized based on the target branch (i.e. "Merge branchx" vs. "Merge branchx into branchy") (builtin/fmt-merge-msg.c)
  • git init uses master as the default branch name (builtin/init-db.c)
  • git submodule defaults to master when a branch name isn't specified (builtin/submodule--helper.c)

(the git-remote.c and files-backend.c outputs from below don't actually interact with the master branch)


The list above was compiled by using the following git grep on the git repository.

# Look for string literals within *.c files containing "master" 
# with 10 lines of context, excluding the t/ and contrib/ directories
$ git grep -C 10 -E -e \".*master.*\" -- :**/*.c :^t/ :^contrib/
chuckx
  • 6,484
  • 1
  • 22
  • 23
1

master is used as a default in some places.

  • The first branch in an empty repository is done ino the master branch.
  • Merge commit messages either are "Merge branch x" or "Merge branch x into y" when y != master

But besides of this kind of stuff a branch named master is not really necessary.

A.H.
  • 63,967
  • 15
  • 92
  • 126