What exactly is the default git branch

Viewed 968

Is this a native git concept?

I've been researching this for a while and cannot seem to understand? All I get is Github documentation, and just that master is the initial default branch.

If possible, can someone please explain what this concept means native git-wise.

EDIT: For instance, what setting or idea makes one particular branch the default one ( not necessarily the initial one, but on an ongoing basis ) , and how would one change it outside of something like Github

My intuition is telling me it's where HEAD is pointing to ( in a repository you clone and merge back into, like a bare repository on a server ) in a more general sense, is this close?

Ty!

2 Answers

Is this a native git concept?

No. It's a GitHub (and other host) concept. It goes with pull requests, which are also not a Git concept.

When you make a pull request at GitHub, you push a branch; what branch should GitHub offer, by default, to merge your pull request branch into? That is the default branch.

Branches are not a GitHub concept but a source code repository concept.

Default branch in Git (basics)

The master (or nowadays optionally main) branch is always the default branch in a repository. You can work on a copy of a branch to build independent features without breaking or affecting the production code. You can also clone a specific branch from a repository.

I found this blog post surely interesting for beginners.

Default Branch in Jenkins

In Jenkins you have to set a default branch, see here:

Branch to be checked out in the workspace. Default is ' master '. Note that this must be a local branch name like 'master' or 'develop'. Remote branch names like 'origin/master' and 'origin/develop' are not supported as the branch argument.

You can set up builds for one or multiple specific branches, see this SO post.

Related