GIT / A CONCEPT NOTE

Branching & Merging

parallel work, one history

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

A branch is just a pointer to a commit hash. Merging integrates commits from a feature branch into the target branch, either via fast-forward or a merge commit.

02 / FOLLOW THE MECHANISM

How branch integration flows

  1. Branch create

    creates pointer tag: git checkout -b feature-a from main.

  2. Feature edits

    makes commits on feature-a, moving feature-a pointer forward.

  3. Merge call

    checks out main, calls git merge feature-a.

  4. Merge Commit

    git creates a new commit containing two parent hashes (main and feature-a).

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

force git to create a merge commit even if fast-forward is possible

git merge --no-ff feature-branch

Explore command anatomy in the CLI lab