我如何从当前工作树中删除未跟踪的本地文件 ?
当前回答
用户互动办法:
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 用于交互式
-f 用于武力
-d 用于目录
- 被忽略文件的x( 需要时添加)
注: 添加添加添加- n,n或-- 干燥运行检查它能做什么
其他回答
清除未跟踪文件的简单方式
要删除所有未跟踪的文件,简单的方法就是先加全部和重置重置( R)如下所示
git add --all
git reset --hard HEAD
我刚刚发明和尝试的这种情形的救生衣(非常有效):
git add .
git reset --hard HEAD
当心!确定承诺任何所需的更改(甚至在未跟踪的文件中)执行前先执行.
使用git reset HEAD <file>
以卸开一个文件
如果未跟踪的目录是自有的 git 仓库( 如子模块) , 您需要使用-f
两次:
git clean -d -f -f
(d) [-f] [-n] [-q] [-e] [-x -X] [-]...
-q, --quiet do not print names of files removed
-n, --dry-run dry run
-f, --force force
-i, --interactive interactive cleaning
-d remove whole directories
-e, --exclude <pattern>
add <pattern> to ignore rules
-x remove ignored files, too
-X remove only ignored files
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式