如何从当前工作树中删除未追踪的本地文件?


当前回答

git add --all, git stash and git stash drop, try these three commands in this order in order to remove all untracked files. 通过添加所有这些未追踪的文件到 git 并 stashing 它们将移动所有这些未追踪的文件到 stash 列表并下载顶部一个,即, stash@{0} 将从 stash 列表中删除所有未追踪的文件。

其他回答

我认为最安全、最容易的方式就是这样!

git add .
git stash 

更多信息 https://www.atlassian.com/git/tutorials/saving-changes/git-stash#stashing-your-work

git clean -f

将从当前 git 中删除未追踪的文件

git clean -fd

当您要删除目录和文件时,此只会删除未追踪的目录和文件。

清除 git 存储库和所有子模块重复 以下命令将清除当前 git 存储库和所有子模块重复: (git clean -d -x -f& git submodule foreach --recursive git clean -d -x -f)

git clean -f 从工作目录中删除未追踪的文件。

我在我的博客中包含了一些基本内容, git-intro-basic-commands

正常的 git 清洁命令不会用我的 git 版本 2.9.0.windows.1 删除未追踪的文件。

$ git clean -fdx     # doesn't remove untracked files
$ git clean -fdx *   # Append star then it works!