Skip to content
Commitpedia
Log in Join & edit

What is a branch?

A branch is a separate line of work in Git, so you can try changes without touching the main version of the project.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of What is a branch?: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
1 min

A branch is a movable pointer to a commit that lets a project grow in several directions at once. Imagine a tree: the trunk is the main version, and each branch grows new leaves that may or may not be grafted back later. In Git, creating a branch is instant and costs nothing, so people make one for every feature or bug fix.

Most teams keep a protected main branch that always works, and do their day-to-day work on feature branches like fix-login. When the work is ready, the branch is merged back, usually through a pull request. Switching branches changes the files in your folder to match that branch, which can feel like magic the first time.

git switch -c fix-login
git branch

See also: What is a commit? and What is a merge conflict?

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0034 Merging vs rebasing in Git Merge and rebase both bring commits from one branch into another. Merge keeps history exactly as it happened; rebase replays your commits… Intermediate · Explains an idea · Any system Article Branching & rebasing 15 Oct 2026
  • 0041 Fix: CONFLICT (content): Merge conflict in … Two branches changed the same lines and Git cannot choose for you. Open the file, keep the right text, remove the markers,… Intermediate · Fixes an error · Any system Article Branching & rebasing · Common errors 15 Oct 2026
  • 0262 Make your first pull request: Git and GitHub from first commit to merged change A complete beginner's path through Git and GitHub: set up Git, make commits, ignore files, use branches, push to GitHub, open a… Beginner · Guided project · Any system Article Branching & rebasing · Pull requests · Setup 15 Oct 2026
  • 0269 What is a commit? A commit is a saved snapshot of your project in Git, with a message explaining what changed and why. Beginner · Explains an idea · Any system Article Branching & rebasing 15 Oct 2026
  • 0271 What is a merge conflict? A merge conflict happens when two branches changed the same lines and Git needs a human to decide which version wins. Beginner · Explains an idea · Any system Article Branching & rebasing 15 Oct 2026

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +750 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?