Skip to main content
Merging combines changes from one Git branch into another so you can integrate separate work into a single codebase. This guide shows a simple local merge workflow (fast-forward example), how to inspect history afterward, and how to clean up the feature branch. Scenario
  • Branch exploring-coloring: player starts with 5 lives and UI color changed to green.
  • Branch main: player starts with 3 lives and original colors remain.
Below are the relevant file excerpts before merging. script.js on main (shows 3 lives):
script.js on exploring-coloring (shows 5 lives and a few UI tweaks):
When to expect a fast-forward merge A fast-forward merge happens when the target branch (e.g., main) has no new commits since the source branch diverged. In that case Git simply moves the main pointer forward so it points to the same commit as the source branch. If both branches have unique commits, Git creates a merge commit unless you rebase first. Performing a local merge (fast-forward example)
  1. Checkout the target branch you want to merge into (usually main).
  2. Merge the source branch into it.
Example commands and output:
After this fast-forward merge, main now includes the updates from exploring-coloring (player starts with 5 lives and the styling changes). Run the app from main to verify the UI and behavior. Quick reference: common git merge commands Inspecting commit history Use a compact graph log to confirm branches were combined and to visualize commit pointers. Example:
In this example both main and exploring-coloring point to the same latest commit after the fast-forward. Deleting the feature branch locally If you no longer need the feature branch locally, delete it to keep your branch list tidy. Example:
Final history after deletion:
Fast-forward merges are simple and clean: Git advances the target branch pointer when there are no divergent commits. If your branches have diverged, Git will create a merge commit. Teams often choose between merge commits and rebasing based on their preferred history style—pick the workflow that matches your team’s collaboration model.
Summary
  • Local merging: git checkout <target> then git merge <source>.
  • Fast-forward merges move the branch pointer without creating a merge commit.
  • Always verify the merge by opening files, running the app, and inspecting the log.
  • Clean up local feature branches with git branch --delete <branch> when they’re no longer needed.
Related resources

Watch Video