0
0
Gitdevops~20 mins

Merge strategies overview in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Merge Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Git Merge Strategies

Which Git merge strategy creates a new commit when fast-forward is not possible?

Aours
Bresolve
Coctopus
Drecursive
Attempts:
2 left
💡 Hint

Think about the default strategy Git uses for two-parent merges that preserves history.

💻 Command Output
intermediate
2:00remaining
Output of a Fast-Forward Merge

What is the output of the following Git command sequence?

git checkout main
git merge feature-branch

Assuming main is behind feature-branch and no conflicts exist.

A
Updating abc123..def456
Fast-forward
BMerge made by recursive.
CAutomatic merge failed; fix conflicts and then commit the result.
DAlready up to date.
Attempts:
2 left
💡 Hint

Consider what happens when the current branch can be moved forward without creating a merge commit.

Configuration
advanced
2:00remaining
Configuring Git to Always Use the 'Ours' Merge Strategy

Which Git configuration command sets the default merge strategy to ours for all merges?

Agit config --global merge.default ours
Bgit config --global merge.default-strategy ours
Cgit config --global merge.strategy ours
Dgit config --global merge.strategy.default ours
Attempts:
2 left
💡 Hint

Look for the correct Git config key for setting the merge strategy.

Troubleshoot
advanced
2:00remaining
Troubleshooting a Failed Octopus Merge

You attempt to merge three branches at once using the octopus strategy but get an error. What is the most likely cause?

AThere are conflicts between at least two branches.
BThe octopus strategy only supports merging two branches.
CThe branches have diverged too much for any merge.
DThe repository is in a detached HEAD state.
Attempts:
2 left
💡 Hint

Octopus merges multiple branches but has limitations.

🔀 Workflow
expert
3:00remaining
Choosing the Correct Merge Strategy for a Complex Workflow

You have a long-running feature branch and want to keep its history linear on the main branch but still incorporate upstream changes regularly. Which Git merge strategy and workflow combination best fits this need?

AUse 'git merge -s ours' to ignore upstream changes and keep feature branch history.
BUse 'git rebase' on the feature branch regularly before merging with fast-forward.
CUse 'git merge --no-ff' to create merge commits preserving history.
DUse 'git merge --squash' to combine all changes into one commit on main.
Attempts:
2 left
💡 Hint

Think about keeping a clean, linear history while incorporating upstream changes.