如何从当前工作树中删除未追踪的本地文件?
当前回答
git-clean - 从工作树中删除未追踪的文件
其他回答
我很惊讶以前没有人提到这一点:
git clean -i
它是互动的,你会得到一个快速的概述,什么将被删除,为您提供包含 / 排除受影响的文件的可能性。
你必須在 -d 如果你也想照顧空的文件夾。
git iclean
说到这一点,对互动命令的额外持有可能令人兴奋的经验丰富的用户,如今我只使用已经提到的 git clean -fd
取消完整的更改 git clean -f -d
$ git clean -f -d
Removing client/app/helpers/base64.js
Removing files/
Removing package.json.bak
where
-f is force
-d is a directory
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-clean - 从工作树中删除未追踪的文件
我用这个:
git 状态 复制文件路径 rm <文件路径>
我的项目有很多由一个巨大的 ANT 构建脚本创建的创建文件,使用 git clean 会产生混乱。