CS FundamentalsModerateTCS · Wipro · Git interview
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 command does exactly that?
- A. git restore app.py
- B. git checkout -- app.py
- C. git reset --hard
- D. git restore --staged app.py
Correct answer: D. git restore --staged app.py
git restore --staged (like git reset app.py) removes the file from the index but leaves the working-tree edits. git restore app.py and git checkout -- app.py discard working-tree changes; reset --hard discards everything.
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
- 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?
- A repository has untracked files temp.txt and out/build.log; .log is in .gitignore. What does git clean -fd remove?
- Assertion (A): You should not rebase commits that others have already based work on. Reason (R): Rebasing creates new commits with new…
- You run git branch -d experiment and Git refuses: 'the branch is not fully merged'. You force it with git branch -D. Which statement is…
- While running git rebase main on your feature branch, a conflict appears. In this situation, what do git checkout --ours and --theirs…