Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a three-way merge in Git?
A three-way merge in Git combines changes from two branches using a common base version to create a new merged version.
Click to reveal answer
beginner
What are the three points used in a three-way merge?
The three points are: the base (common ancestor), the source branch, and the target branch.
Click to reveal answer
intermediate
Why is the base version important in a three-way merge?
The base version helps Git understand what changed in each branch to combine changes correctly and detect conflicts.
Click to reveal answer
intermediate
What happens if changes conflict during a three-way merge?
Git marks the conflict and pauses the merge so you can manually fix the conflicting parts before completing the merge.
Click to reveal answer
beginner
How do you start a three-way merge in Git?
You run 'git merge ' while on the target branch to merge changes from the source branch.
Click to reveal answer
What does the 'base' represent in a three-way merge?
AThe latest commit on the source branch
BThe common ancestor commit of both branches
CThe latest commit on the target branch
DThe commit with conflicts
✗ Incorrect
The base is the common ancestor commit from which both branches diverged.
Which Git command initiates a three-way merge?
Agit merge <branch-name>
Bgit rebase <branch-name>
Cgit commit
Dgit checkout <branch-name>
✗ Incorrect
The 'git merge' command merges changes from another branch using a three-way merge.
What does Git do when it detects conflicts during a three-way merge?
AIgnores conflicts and completes the merge
BAutomatically discards conflicting changes
CStops and asks you to resolve conflicts manually
DDeletes the source branch
✗ Incorrect
Git pauses the merge and marks conflicts for manual resolution.
Why is a three-way merge better than a two-way merge?
AIt uses the base version to understand changes from both branches
BIt merges only one branch
CIt deletes the base branch
DIt avoids any conflicts
✗ Incorrect
Using the base helps Git combine changes more accurately.
Which of these is NOT part of a three-way merge?
ABase commit
BSource branch commit
CTarget branch commit
DRemote repository URL
✗ Incorrect
The remote URL is unrelated to the three commits used in a three-way merge.
Explain the process of a three-way merge in Git and why it is useful.
Think about how Git uses three points to combine changes safely.
You got /5 concepts.
Describe what happens when Git encounters conflicts during a three-way merge and how you resolve them.
Focus on the steps after conflicts appear.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of a three-way merge in Git?
easy
A. To combine changes from two branches using a common base
B. To delete a branch after merging
C. To create a new branch from the current branch
D. To reset the current branch to a previous commit
Solution
Step 1: Understand the concept of three-way merge
A three-way merge uses the common ancestor of two branches to combine their changes safely.
Step 2: Identify the purpose in Git workflow
This process helps merge changes from two branches without losing work, especially when both branches have edits.
Final Answer:
To combine changes from two branches using a common base -> Option A
Quick Check:
Three-way merge = combine changes safely [OK]
Hint: Three-way merge combines two branches with a common ancestor [OK]
Common Mistakes:
Confusing merge with branch deletion
Thinking merge creates new branches
Mixing merge with reset commands
2. Which Git command automatically performs a three-way merge when integrating changes from a remote branch?
easy
A. git pull
B. git merge
C. git commit
D. git branch
Solution
Step 1: Recall commands that fetch and merge
git pull fetches changes from a remote branch and merges them locally, often using a three-way merge.
Step 2: Differentiate from other commands
git merge merges branches locally but does not fetch remote changes; git branch manages branches; git commit records changes.
Final Answer:
git pull -> Option A
Quick Check:
git pull = fetch + merge (three-way) [OK]
Hint: git pull fetches and merges remotely with three-way merge [OK]
Common Mistakes:
Choosing git merge without fetching first
Confusing git commit with merge
Using git branch for merging
3. Given the following scenario:
Branch A has file.txt with content: "Hello World"
Branch B modifies file.txt to: "Hello Git"
Common base has file.txt: "Hi World"
What will be the content of file.txt after a successful three-way merge of Branch B into Branch A?
medium
A. "Hello"
B. "Hello Git"
C. "Hello World Git"
D. "Hello World"
Solution
Step 1: Identify changes from base to each branch
Base has "Hi World". Branch A changed "Hi" to "Hello". Branch B changed "Hi" to "Hello" and "World" to "Git".
Step 2: Understand three-way merge result
Since the change "Hi" -> "Hello" is common to both branches, and Branch B has an additional change "World" -> "Git", Git's three-way merge automatically combines them, resulting in "Hello Git".
Final Answer:
"Hello Git" -> Option B
Quick Check:
Three-way merge picks combined changes, here "Hello Git" [OK]
Hint: Merged content reflects changes from both branches via base [OK]
Common Mistakes:
Assuming content concatenates both changes
Ignoring base version in merge
Confusing which branch's changes apply
4. You ran git merge feature but got a conflict in app.js. What should you do to resolve this three-way merge conflict?
medium
A. Run git reset --hard immediately to discard all changes
B. Delete app.js and run git merge --abort
C. Edit app.js to fix conflicts, then run git add app.js and git commit
D. Run git branch -d feature to delete the feature branch
Solution
Step 1: Understand merge conflict resolution
When a conflict occurs, you must manually edit the conflicting file to resolve differences.
Step 2: Stage and commit resolved file
After fixing conflicts in app.js, use git add to stage and then git commit to complete the merge.
Final Answer:
Edit app.js, then git add and git commit -> Option C
Quick Check:
Fix conflicts, stage, commit to resolve merge [OK]
Hint: Fix conflicts manually, then add and commit [OK]
Common Mistakes:
Deleting files instead of resolving conflicts
Aborting merge without fixing conflicts
Deleting branches to fix conflicts
5. You have two branches, main and feature. Both modified the same function in utils.py differently. After running git merge feature into main, a three-way merge conflict occurs. Which approach best resolves this conflict while preserving both changes?
hard
A. Delete feature branch and continue with main unchanged
B. Force merge with git merge --strategy=ours to keep main version only
C. Reset main to the common ancestor commit and retry merge
D. Manually edit utils.py to combine both changes logically, then stage and commit
Solution
Step 1: Recognize conflict in same function
Both branches changed the same function differently, causing a conflict during merge.
Step 2: Choose best resolution method
Manually editing the file to combine both changes logically preserves work from both branches, which is the best practice.
Step 3: Stage and commit after resolving
After editing, stage the file with git add and commit to complete the merge.
Final Answer:
Manually edit utils.py to combine changes, then stage and commit -> Option D
Quick Check:
Manual merge preserves both changes best [OK]
Hint: Edit conflicts to combine changes, then add and commit [OK]