What is the command to list all untracked files in Git?

What is the command to list all untracked files in Git?

a) git status
b) git ls-files --others
c) git show untracked
d) git log --untracked

Answer:

b) git ls-files --others

Explanation:

The command git ls-files --others lists all untracked files in your working directory. These are files that have not been added to the index (staging area) and are not being tracked by Git.

Alternatively, you can use git status to see untracked files along with other status information.

Knowing which files are untracked is important when deciding which files to include in your repository.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top