Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Git commands: Git Grep: Repository-Aware Search

Create a disposable repository with tracked files under `src/` and `docs/`. Commit content containing the same search term in multiple files. Then create a staged change, an untracked file, and an ignored file containing distinguishable variants of the term. Demonstrate with captured output: a normal working-tree search; a line-numbered, case-insensitive search limited to `src/`; an index search with `--cached`; a committed-tree search against `HEAD`; an untracked-file search with `--untracked`; and a filename-only search with `-l`. Your evidence must show which repository state each command searched and must not rely on an external recursive `grep` command.

Advanced ~6 min read

Challenge 1

Complete the Git command to search tracked repository content.

bash Your answer
git 

Press Ctrl⌘Enter to check your answer

Challenge 2

Complete the Git command to search tracked repository content.

bash Your answer
git  'pattern'

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the Git command to search tracked repository content.

bash Your answer
git  --cached 'pattern'

Press Ctrl⌘Enter to check your answer

Challenge 4

Complete the Git command to search tracked repository content.

bash Your answer
git  'pattern' HEAD

Press Ctrl⌘Enter to check your answer