CS FundamentalsModerateTCS · Infosys · Git interview

A feature branch is merged into main with git merge --no-ff feature, although main had not moved since feature branched. What is the result?

  1. A. Git fast-forwards anyway because no merge is needed
  2. B. A merge commit is created, preserving the feature's commits as a visible side branch in history
  3. C. The feature's commits are squashed into one
  4. D. Git refuses because --no-ff needs diverged branches

Correct answer: B. A merge commit is created, preserving the feature's commits as a visible side branch in history

--no-ff forces a merge commit even when a fast-forward is possible, recording that a group of commits belonged to one feature. Teams use it so the feature can be reverted as one unit.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic