CS FundamentalsVery hardProduct-company placement · Git interview
main has commits A-B-C-D. feature was created at B and has commits E-F. How many commits do git log main..feature and git log main...feature list?
- A. 2 and 2
- B. 2 and 6
- C. 4 and 2
- D. 2 and 4
Correct answer: D. 2 and 4
main..feature lists commits reachable from feature but not from main: E and F. The three-dot form is the symmetric difference, commits on either side but not both: C, D, E and F.
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
- On main (…-C-D) you run git merge feature, where feature has E-F-G, creating merge commit M. Its first parent is D and its second is G…
- On main with tip D (history A-B-C-D) you accidentally run git reset --hard HEAD~2. Which command brings the branch back to D, assuming…
- A merge commit M on main brought in a feature that turns out to be broken. Running git revert M fails. Why, and what is the fix?
- feature has commits X, then Y, then Z (oldest to newest). On main you run git cherry-pick X..Z. Which commits are applied?
- Your working tree has a modified tracked file f.txt and a new, never-added file u.txt. You run git stash. What does git status show next?
- A .gitignore contains the two lines logs/ and !logs/keep.log. A developer expects logs/keep.log to be tracked, but git status never shows…