CS FundamentalsHardProduct-company placement · Git interview
After rebasing your branch you must update the remote branch. A colleague may have pushed to the same branch meanwhile. Why prefer git push --force-with-lease over git push --force?
- A. --force-with-lease squashes your commits before pushing
- B. --force-with-lease pushes tags as well
- C. --force-with-lease refuses to overwrite if the remote branch has moved from what your local remote-tracking ref last saw, so a colleague's new commits are not silently destroyed
- D. --force-with-lease creates a backup branch on the remote
Correct answer: C. --force-with-lease refuses to overwrite if the remote branch has moved from what your local remote-tracking ref last saw, so a colleague's new commits are not silently destroyed
--force blindly replaces the remote ref. --force-with-lease only succeeds if the remote still points where you expect, protecting work pushed after your last fetch.
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
- You create an annotated tag v2.0 locally and run git push. The tag does not appear on the remote. What is correct?
- A file config.env holding a live API key was committed and pushed three weeks ago. The developer now runs git rm --cached config.env, adds…
- How many of these statements about Git's object model are correct? 1. Two files with identical content in different folders are stored as…
- You pushed commit C to a shared branch, then ran git commit --amend to fix its message and tried git push again. What happens and why?
- 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…
- In GitFlow, a critical bug is found in production (main) while develop holds unreleased work. What is the standard handling?