0
0
Gitdevops~20 mins

Fast-forward merge in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Fast-forward Merge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is a fast-forward merge in Git?

Which statement best describes a fast-forward merge in Git?

AIt deletes the source branch after merging automatically.
BIt creates a new merge commit even if the branches have no divergent changes.
CIt moves the branch pointer forward without creating a new commit when there are no divergent changes.
DIt rewrites the commit history to remove merge commits.
Attempts:
2 left
💡 Hint

Think about what happens when the target branch has no new commits since branching.

💻 Command Output
intermediate
2:00remaining
Output of fast-forward merge command

Given the following Git commands executed in order, what is the output of the final git merge feature command?

git checkout main
# main points to commit A

git checkout -b feature
# feature branch created from A

git commit --allow-empty -m "Add feature"
# feature now points to commit B

git checkout main

git merge feature
AMerge made by the 'recursive' strategy.
Berror: You have unmerged paths.
CAlready up to date.
D
Updating A..B
Fast-forward
Attempts:
2 left
💡 Hint

Consider if the main branch has new commits after branching.

🔀 Workflow
advanced
1:30remaining
When does Git refuse a fast-forward merge?

Which situation will cause Git to refuse a fast-forward merge by default?

AWhen the target branch has new commits not in the source branch.
BWhen the branches are identical.
CWhen the source branch is ahead and no new commits exist on the target branch.
DWhen the source branch is behind the target branch.
Attempts:
2 left
💡 Hint

Think about what happens if both branches have new commits.

Troubleshoot
advanced
1:30remaining
Why does 'git merge --ff-only' fail?

You run git merge --ff-only feature but get the error: fatal: Not possible to fast-forward, aborting. What is the most likely cause?

AThe feature branch is fully merged already.
BThe target branch has commits that the feature branch does not have.
CYou have uncommitted changes in your working directory.
DThe feature branch does not exist.
Attempts:
2 left
💡 Hint

Consider what --ff-only means for the merge.

Best Practice
expert
2:00remaining
Choosing merge strategy for a clean history

You want to keep your Git history linear and clean without merge commits. Which command ensures merges only happen if they can fast-forward?

Agit merge --ff-only feature
Bgit merge --no-ff feature
Cgit merge --squash feature
Dgit merge --no-commit feature
Attempts:
2 left
💡 Hint

Think about which option prevents merge commits.