git untracked files - how to ignore

44,531

Solution 1

You need to create one or several .gitignore files. They can be stored in git itself, or just kept local.

Solution 2

Files that are "yours", files that no one else sees, write in .git/info/exclude.

For files that everyone else sees, write them down in .gitignore at the project top directory and then add and commit the .gitignore file.

For example, your .gitignore might look like so:

*.o
.*.sw[op]
*~

Solution 3

You can make git ignore all files that match a regular expression (like all files *.ext) by adding the line *.ext in file .git/info/exclude.

Added Abe Voelker's comment bellow to improve the answer:

Note that this approach is local to your repository. If you ever clone it (e.g. share it with others), your ignore settings will not be pulled in.

If you need to share the ignore settings, you should put it in .gitignore files

Solution 4

To ignore, use .gitignore, as Sam Hocevar said.

To delete, you'll probably want to do a git clean, which will clean up any files that aren't tracked by git. You might need to use the -f and -d switches if you've got directories which aren't tracked.

Be careful with git clean, it will delete things you haven't added to git yet!

Solution 5

If you want to do this globally all the time do

git config status.showuntrackedfiles no
Share:
44,531
JDesigns
Author by

JDesigns

Updated on November 23, 2020

Comments

  • JDesigns
    JDesigns over 3 years

    When I run git status, I see the "Untracked files" section has many files (some with a "." extension.)

    I don't think I have to do anything, but it doesnt look good to see these files whenever I run git status. Is there any way to not to see these files?