CS FundamentalsHardAccenture · Infosys · Git interview
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. u.txt as untracked; f.txt is stashed and clean
- B. A clean working tree; both files are stashed
- C. f.txt as modified; only u.txt is stashed
- D. Nothing changes, because stash needs a commit message
Correct answer: A. u.txt as untracked; f.txt is stashed and clean
By default git stash saves tracked changes (staged and unstaged) only; untracked files stay. git stash -u (or --include-untracked) would stash u.txt too.
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 .gitignore contains the two lines logs/ and !logs/keep.log. A developer expects logs/keep.log to be tracked, but git status never shows…
- A team lead adds a pre-commit hook to .git/hooks/pre-commit in her repository and pushes. Teammates who clone the repository report that…
- After rebasing your branch you must update the remote branch. A colleague may have pushed to the same branch meanwhile. Why prefer git…
- 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…