linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Branches & merging

kb/branching

Git branches: branch, merge, rebase, cherry-pick

Git branches and how to combine them: a branch is a file holding one SHA, fast-forward and three-way merge, rebase for rewriting history, cherry-pick for moving a single commit. The section compares merge against rebase and shows you when to use each one.

  • branchBranch

    A branch in Git is a file inside `.git/refs/heads/` that holds the SHA of one commit. Creating, switching, and deleting branches are trivial operations because a branch contains exactly 41 bytes of data.

  • detached-headDetached HEAD

    A state in which HEAD points directly at a commit rather than at a branch. Safe for reading and exploring, but any commits you make in this mode are lost unless you create a branch from them.

  • fast-forwardFast-forward merge

    The simplest form of merge: Git moves the branch pointer to the new commit without creating a merge object. Possible only when the target branch has no commits of its own since the point of divergence.

  • cherry-pickgit cherry-pick

    Takes one commit from another branch and applies it to the current one, creating a duplicate with a new SHA. Used for hotfixes across multiple release branches and for moving individual commits.

  • mergegit merge

    Merges another branch into the current one. Either fast-forwards the pointer or creates a merge commit with two parents. Overlapping changes produce conflicts.

  • rebasegit rebase

    Rewrites the commits of a branch so they descend from a different commit. Each commit gets a new SHA; history becomes linear. Safe only on branches that no one else has seen.

  • interactive-rebaseInteractive rebase

    `git rebase -i <base>` opens an editor with the list of commits from `<base>` to HEAD, where you can rename, combine, delete, and reorder them. It is the primary tool for cleaning up local history.

Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies