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?
- A. (i) 4, (ii) 7, (iii) 6
- B. (i) 3, (ii) 6, (iii) 6
- C. (i) 4, (ii) 6, (iii) 7
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- In GitFlow, a critical bug is found in production (main) while develop holds unreleased work. What is the standard handling?
- A team practising trunk-based development wants to merge a half-built feature into main daily without exposing it to users. What makes…
- You have 2 local commits on main and the remote main has 3 new commits. What does git pull --rebase do?
- You staged changes to app.py with git add but now want them out of the next commit while keeping the edits in your working tree. Which…
- During git rebase main, a conflict stops the rebase. You edit the file to resolve it. What should you do next?
- After git fetch, git status says: "Your branch is behind 'origin/main' by 3 commits, and can be fast-forwarded." Which statement is correct?