Which statement best describes a fast-forward merge in Git?
Think about what happens when the target branch has no new commits since branching.
A fast-forward merge simply moves the branch pointer forward to the latest commit if there are no divergent changes, avoiding a merge commit.
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
Consider if the main branch has new commits after branching.
Since main has no new commits after branching, the merge is a fast-forward and Git outputs 'Updating A..B' and 'Fast-forward'.
Which situation will cause Git to refuse a fast-forward merge by default?
Think about what happens if both branches have new commits.
If the target branch has new commits not in the source branch, Git cannot fast-forward and will create a merge commit or refuse fast-forward if configured.
You run git merge --ff-only feature but get the error: fatal: Not possible to fast-forward, aborting. What is the most likely cause?
Consider what --ff-only means for the merge.
The --ff-only option refuses to create a merge commit. If the target branch has commits not in the feature branch, fast-forward is impossible and Git aborts.
You want to keep your Git history linear and clean without merge commits. Which command ensures merges only happen if they can fast-forward?
Think about which option prevents merge commits.
The --ff-only option refuses to create merge commits and only merges if a fast-forward is possible, keeping history linear.