git: How to ignore all present untracked files?

前端 未结 8 1599
北恋
北恋 2020-12-22 14:57

Is there a handy way to ignore all untracked files and folders in a git repository?
(I know about the .gitignore.)

So git status would

相关标签:
8条回答
  • 2020-12-22 15:37

    If you want to permanently ignore these files, a simple way to add them to .gitignore is:

    1. Change to the root of the git tree.
    2. git ls-files --others --exclude-standard >> .gitignore

    This will enumerate all files inside untracked directories, which may or may not be what you want.

    0 讨论(0)
  • 2020-12-22 15:39

    If you have a lot of untracked files, and don't want to "gitignore" all of them, note that, since git 1.8.3 (April, 22d 2013), git status will mention the --untracked-files=no even if you didn't add that option in the first place!

    "git status" suggests users to look into using --untracked=no option when it takes too long.

    0 讨论(0)
提交回复
热议问题