如何从当前工作树中删除未追踪的本地文件?
当前回答
git-clean - 从工作树中删除未追踪的文件 同步 git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x♰ -X] [--] <path>... 描述 通过从当前目录开始,不受版本控制的文件重新删除工作树。
# Print out the list of files and directories which will be removed (dry run)
git clean -n -d
# Delete the files from the repository
git clean -f
注意后两个命令的 X 中的案例差异。
其他回答
正常的 git 清洁命令不会用我的 git 版本 2.9.0.windows.1 删除未追踪的文件。
$ git clean -fdx # doesn't remove untracked files
$ git clean -fdx * # Append star then it works!
用户互动方法:
git clean -i -fd
Remove .classpath [y/N]? N
Remove .gitignore [y/N]? N
Remove .project [y/N]? N
Remove .settings/ [y/N]? N
Remove src/com/arsdumpgenerator/inspector/ [y/N]? y
Remove src/com/arsdumpgenerator/manifest/ [y/N]? y
Remove src/com/arsdumpgenerator/s3/ [y/N]? y
Remove tst/com/arsdumpgenerator/manifest/ [y/N]? y
Remove tst/com/arsdumpgenerator/s3/ [y/N]? y
-i for interactive -f for force -d for directory -x for ignored files(添加必要时) 注意: 添加 -n 或 -dry-run 只需检查它会做什么。
git clean -fd 删除目录
git clean -fX 删除被忽略的文件
git clean -fx 删除被忽略和未被忽略的文件
可以使用上述所有选项,如
清洁 -fdXx
查看 git 手册 获取更多帮助
清除 git 存储库和所有子模块重复 以下命令将清除当前 git 存储库和所有子模块重复: (git clean -d -x -f& git submodule foreach --recursive git clean -d -x -f)
git-clean - 从工作树中删除未追踪的文件 同步 git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x♰ -X] [--] <path>... 描述 通过从当前目录开始,不受版本控制的文件重新删除工作树。
# Print out the list of files and directories which will be removed (dry run)
git clean -n -d
# Delete the files from the repository
git clean -f
注意后两个命令的 X 中的案例差异。
推荐文章
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支
- 自定义SSH端口上的Git
- git如何显示不存在于.gitignore中的未跟踪文件
- Git错误:遇到7个文件应该是指针,但不是
- GitHub克隆与OAuth访问令牌
- 移动(或“撤销”)最后一个git提交到非暂存区域