CS FundamentalsVery hardProduct-company placement · Git interview
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 it. Why?
- A. Negation patterns are not supported in .gitignore
- B. The negation must come before the directory pattern
- C. Git cannot re-include a file whose parent directory is excluded; using logs/* instead of logs/ fixes it
- D. keep.log must be committed with git add -f once, after which the negation takes effect
Correct answer: C. Git cannot re-include a file whose parent directory is excluded; using logs/* instead of logs/ fixes it
logs/ excludes the directory itself, so git never looks inside it and the negation has nothing to act on. logs/* ignores the contents instead, letting !logs/keep.log re-include that one file.
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 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…
- 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?