关于版本控制:告诉Git它可以删除未跟踪的文件

Telling git its ok to remove untracked files

本问题已经有最佳答案,请猛点这里访问。

Possible Duplicate:
How do you remove untracked files from your git working copy?

是否可以告诉Git删除未跟踪的文件?主要是类似于重置的东西?

例子:

1
2
git checkout -- index.php <-- revert my file
git checkout -- master <-- this would revert the entire repo back to the last commit on master, removing (deleting) any and all untracked files as well as reverting committed ones.

我知道这是一个微不足道的托多壳,但我想知道这是否可以在吉特?


你需要git clean但要加载-df才能从你所在的方向上清除那些文件。包括不知道的文件。

So to completely clean your working directory only leaving what is in source control,issue this command:

ZZU1


你可能正在寻找This will delete all untracked files.用这个不知道的方式(不删除)在.gitignore中的模式,但是git clean -x清洁这些文件。

From the git clean

1
2
3
4
5
   -x
       Don't use the ignore rules. This allows removing all untracked
       files, including build products. This can be used (possibly in
       conjunction with git reset) to create a pristine working directory
       to test a clean build.