What this animation explains
A merge may automatically combine independent changes or stop when overlapping edits cannot be reconciled. The common ancestor lets Git distinguish independent changes from competing replacements.

MODULE 6 · TOPIC 8 · VISUAL GIT LAB
Git performs a three-way merge using a common ancestor, the current branch tip and the incoming branch tip. Non-overlapping edits are often merged automatically. Overlapping edits can require a human decision; conflict markers identify alternative text, while the index stores unmerged stages. Review the intended behavior, resolve files, stage them, test and commit. You can abort a merge to return to its previous state, especially when starting from a clean tree.
Interactive replays of recorded Git 2.47 command traces. The browser changes only the simulation; no local files, Git repositories or hosting accounts are modified. Commit graphs run from parent to child.
A merge may automatically combine independent changes or stop when overlapping edits cannot be reconciled. The common ancestor lets Git distinguish independent changes from competing replacements.
Why this example? Compare separate-file changes with same-line edits.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
A merge may automatically combine independent changes or stop when overlapping edits cannot be reconciled. The common ancestor lets Git distinguish independent changes from competing replacements.
Inspect working tree and commit graph after merge.
During an ordinary merge, stage 1 is the base, stage 2 is ours and stage 3 is theirs. The working file contains conflict markers in text conflicts. Neither side should be accepted blindly.
Why this example? Inspect conflict markers or the separate index versions.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
During an ordinary merge, stage 1 is the base, stage 2 is ours and stage 3 is theirs. The working file contains conflict markers in text conflicts. Neither side should be accepted blindly.
Read the base, ours and theirs content.
Resolution means choosing correct resulting content. Taking ours, theirs or a combined edit changes the working file; git add then marks the path resolved.
Why this example? Select alternative resolution and finish the merge.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
Resolution means choosing correct resulting content. Taking ours, theirs or a combined edit changes the working file; git add then marks the path resolved.
Compare final file content while commit parents remain the same branches.
When a merge is in progress, abort attempts to reconstruct pre-merge state. Finishing requires resolving all paths and committing. In a clean-start lab these two choices are easy to compare.
Why this example? Compare the history after abort and after completion.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
When a merge is in progress, abort attempts to reconstruct pre-merge state. Finishing requires resolving all paths and committing. In a clean-start lab these two choices are easy to compare.
Check whether HEAD has advanced and whether MERGE_HEAD remains.
Resolving one conflicted path does not resolve other paths. A merge commit cannot be created while unmerged index entries remain.
Why this example? Create two overlapping files and resolve one or both.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
Resolving one conflicted path does not resolve other paths. A merge commit cannot be created while unmerged index entries remain.
Observe git status and the commit refusal until all conflicts are resolved.
Merge preserves original commit identities and may add a merge commit. Rebase replays commits onto a new base, creating new commit IDs. Rebasing private work can make a linear history, but rewriting shared branches needs coordination.
Why this example? Compare rebase and merge for non-overlapping divergent work.
The highlighted path shows the recorded operation. Compare each step with the Git workspace below. Branch arrows run from parent commit to child commit. On small screens, swipe the diagram to read all labels.
Change inputs and step through the example. Outputs are recorded from Git 2.47. Hashes, paths and configuration can differ on your computer. Run worked examples only in fresh practice folders.
Merge preserves original commit identities and may add a merge commit. Rebase replays commits onto a new base, creating new commit IDs. Rebasing private work can make a linear history, but rewriting shared branches needs coordination.
Inspect the parent relationships and changed feature commit hash.
Use these commands in a disposable practice repository. Review the output before running commands that change files or references.
| Git command | Why and when to use it |
|---|---|
| git merge feature | Integrate feature into current branch |
| git status | Inspect conflicting paths |
| git ls-files -u | Inspect base, ours and theirs stages |
| git add app.txt | Mark resolved file staged |
| git commit | Finish merge after resolving |
| git merge --abort | Abort in-progress merge |
Follow these procedures with the Git 2.47 teaching repository (Git Bash, Linux or macOS). Start each example in a separate new practice folder; never run destructive file commands in an important repository.
git init -q -b main git config user.name Student git config user.email student@example.invalid printf "version 1\n" > app.txt git add app.txt git commit -qm "Initial app" git switch -qc feature printf "feature\n" > app.txt git commit -qam "Feature edit" git switch -q main printf "main\n" > app.txt git commit -qam "Main edit" git merge feature # After conflict, execute these commands separately: printf "main and feature\n" > app.txt git add app.txt git diff --cached git commit -m "Resolve merge"
git init -q -b main git config user.name Student git config user.email student@example.invalid printf "version 1\n" > app.txt git add app.txt git commit -qm "Initial app" git switch -qc feature printf "feature\n" > app.txt git commit -qam "Feature edit" git switch -q main printf "main\n" > app.txt git commit -qam "Main edit" git merge feature git merge --abort git status -sb
Try answering these questions, then expand each answer and repeat the appropriate simulation.
Check if unresolved paths remain. Inspect the final state in the lab.
Check the chosen resolution. Inspect the final state in the lab.
Git refuses if any path remains unmerged. Inspect the final state in the lab.
Create two branches that edit the same line, merge, inspect the markers, resolve intentionally, stage and commit. Compare automatic merge, abort and rebase alternatives in disposable repositories.
Edit this command scratchpad. Review the commands and execute only in a disposable Git practice repository; the browser does not run shell commands.
Conflict resolution is a semantic decision, not simply deleting markers. Run relevant tests before committing and avoid rewriting shared history. The examples use a clean pre-merge state.