CS FundamentalsVery hardProduct-company placement · Git interview

main has A-B-X, where X was committed after feature branched from B; feature has C-D-E. How many commits are reachable from main after each option: (i) git merge --squash feature and commit, (ii) git merge --no-ff feature, (iii) rebase feature onto main and fast-forward main?

  1. A. (i) 4, (ii) 7, (iii) 6
  2. B. (i) 3, (ii) 6, (iii) 6
  3. C. (i) 4, (ii) 6, (iii) 7
  4. D. (i) 6, (ii) 7, (iii) 6

Correct answer: A. (i) 4, (ii) 7, (iii) 6

Squash adds one new commit: A, B, X, S = 4. A true merge keeps C, D, E and adds M: 7. Rebasing copies C', D', E' on top of X with no merge commit: 6.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic