Git remove new untracked files

This question already has an answer here:

  • How to remove local (untracked) files from the current Git working tree? 31 answers

  • For your case, you could give an exclude parameter:

    git clean -nd -e **/.gitignore
    

    However, normally, I think it would be recommended to do either of these instead:

  • Commit your .gitignore file. If the ignore rules are useful for everyone who uses the repo, then it makes sense to push it to the remote. git clean will not remove committed files.
  • If you have personal ignore rules, put them in the .git/info/exclude file instead of a .gitignore file. (This is a recommendation from gitignore documentation)

  • 使用-f参数:

    git clean -f
    
    链接地址: http://www.djcxy.com/p/3268.html

    上一篇: 有没有办法从git仓库中删除所有被忽略的文件?

    下一篇: Git删除新的未跟踪文件