CS FundamentalsModerateWipro · Accenture pattern
A developer runs git reset --soft HEAD~1 on a branch. What happens?
- A. The last commit is removed and its changes are deleted from the working directory
- B. The last commit is kept, but a new commit undoing it is added
- C. The last commit is removed from the branch, and its changes stay staged in the index
- D. The changes are unstaged but kept in the working directory
Correct answer: C. The last commit is removed from the branch, and its changes stay staged in the index
--soft moves only the branch pointer; index and working tree are untouched, so the changes are ready to recommit. --mixed (default) would unstage them; --hard would discard them.
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
- A bad commit has already been pushed to a shared main branch that teammates have pulled. What is the safest way to undo it?
- When does git merge feature (run on main) produce a fast-forward instead of a merge commit?
- A stock-price service must notify every registered display widget whenever the price changes, without knowing the widgets' concrete…
- Your application expects a PaymentGateway interface, but the third-party library you must use exposes a different API. Which pattern lets…
- class Square extends Rectangle overrides setWidth() so that it also changes the height. Code that sets width = 5 and height = 4 on a…
- A ReportService creates a new MySqlDatabase() directly inside its constructor. Refactoring it to receive a Database interface through its…