main branch
The branch a repository treats as its primary line of work, usually named main (older repositories often use master).
In more detail
Git has no built-in rule that makes it special; it is whatever the first branch was called (see init.defaultBranch) and what the team agrees to merge into. Hosting services show it by default and usually protect it from direct pushes.
Related terms
- branch — In Git, a movable name for one commit; committing on the branch moves the name forward to the new commit.
- init.defaultBranch — The setting that chooses the name of the first branch in a newly created repository, such as main.
- branch protection rule — A setting on a hosting service that stops changes reaching a branch, usually main, unless conditions such as an approved review and passing checks are met.
- trunk-based development — A branching practice where developers merge small changes into one main branch, the trunk, at least once a day, keeping any other branches short-lived.
Taught in
- Installing Git, And Telling It Who You Are — Advanced Git Internals & Distributed Workflows
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- The Three Areas: Working Tree, Index, Repository — Advanced Git Internals & Distributed Workflows
- Staging Deliberately: status, add, add --patch — Advanced Git Internals & Distributed Workflows
- Committing, And What A Good Message Says — Advanced Git Internals & Distributed Workflows
- Conventional Commits — Advanced Git Internals & Distributed Workflows
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- A Branch Is A Moving Pointer — Advanced Git Internals & Distributed Workflows
- HEAD, And Why Detached HEAD Is Not An Error — Advanced Git Internals & Distributed Workflows
- Merging: Fast Forward Or A Merge Commit — Advanced Git Internals & Distributed Workflows
- Rebase: The Same Work, A Different History — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Clone, Forks, Push, And The Upstream Branch — Advanced Git Internals & Distributed Workflows
- Fetch Is Not Pull — Advanced Git Internals & Distributed Workflows
- The Pull Request, And Branch Naming — Advanced Git Internals & Distributed Workflows
- Reviewing Code Well — Advanced Git Internals & Distributed Workflows
- Why Conflicts Happen — Advanced Git Internals & Distributed Workflows
- Resolving A Conflict, Line By Line — Advanced Git Internals & Distributed Workflows
- Amend, And The One Hard Rule — Advanced Git Internals & Distributed Workflows
- Interactive Rebase: Squash, Reorder, Reword — Advanced Git Internals & Distributed Workflows
- Cherry Picking, Reflog, And Getting Work Back — Advanced Git Internals & Distributed Workflows
- Investigating History: blame, bisect And worktree — Advanced Git Internals & Distributed Workflows
- Trunk Based Development Versus Git Flow — Advanced Git Internals & Distributed Workflows