Git

How Do You Git Show Untracked Files That Do Not Exist in .gitignore?

While working on Git, developers deal with multiple files. When a new file is created, it must be added to the Git staging area for tracking purposes. If the file is not added to the Git index, it is considered an untracked file. Users can view the untracked files by checking the Git status. However, the simple “git status” command sometimes displays the untracked files in the .gitignore folder.

This blog will explain the methods to show untracked files that do not exist in the “.gitignore” file/folder.

How to Git Show/Display Untracked Files That Do Not Exist in .gitignore File/Folder?

Different Git commands are available to display untracked files that are not present in .gitignore, such as:

Method 1: Show Untracked Files Using “git status -u” Command

To display only the untracked files that do not exist in .gitignore, run the “git status” command with the “-u” option:

$ git status -u

The below output indicates that there are two “Test1.txt” and “Test2.txt” untracked files:

Method 2: Show Untracked Files Using “git ls-files . –exclude-standard –others” Command

Enter the following command to list the untracked files in the repository:

$ git ls-files . --exclude-standard --others

It can be seen that the above-stated command has displayed the untracked files that do not exist in the “.gitignore” file/folder:

We have explained two methods to display untracked files that do not exist in the .gitignore file/folder.

Conclusion

To show/display untracked files that are not present in .gitignore, different Git commands can be used, such as the “git status -u” and “git ls-files . –exclude-standard –others” commands. This blog explained the methods to display untracked files that do not exist in the “.gitignore” file/folder.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.