CS FundamentalsVery hardProduct-company placement · Git interview

main has A-B-C. feature1 branched from C with commits D-E, and feature2 branched from E with commits F-G. feature1 is abandoned, but feature2 must go onto main without D and E. What does git rebase --onto main feature1 feature2 produce?

  1. A. C-D'-E'-F'-G' on feature2
  2. B. C-F'-G' on feature2: only the commits in feature2 but not in feature1 are replayed onto main
  3. C. feature1 is moved onto main
  4. D. A merge commit joining feature1 and feature2

Correct answer: B. C-F'-G' on feature2: only the commits in feature2 but not in feature1 are replayed onto main

rebase --onto <newbase> <upstream> <branch> replays the commits reachable from branch but not from upstream (F, G) onto newbase. A plain git rebase main on feature2 would also carry D and E.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic