git:撤消所有工作目录更改,包括新文件 [英] git: undo all working dir changes including new files
本文介绍了git:撤消所有工作目录更改,包括新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何删除工作目录中的所有更改,包括新的未跟踪文件。我知道 git checkout -f
会这样做,但它不会删除自上次提交以来创建的新未跟踪文件。
>有人知道如何做到这一点吗?
解决方案
git reset - 硬#删除上演和工作目录的变化
## !!对这些非常小心!
##你可能最终删除你不想要的
##阅读评论和手册。
git clean -f -d#删除未跟踪的
git clean -f -x -d#注意:如上所示,但删除像config这样的被忽略的文件。
git clean -fxd:/#注意:如上所述,但通过整个repo清除未跟踪和忽略的文件(不包括:/,操作仅影响当前目录)
How to delete all changes from working directory including new untracked files. I know that git checkout -f
does that, but it doesn't delete new untracked files created since last commit.
Does anybody have an idea how to do that?
解决方案
git reset --hard # removes staged and working directory changes
## !! be very careful with these !!
## you may end up deleting what you don't want to
## read comments and manual.
git clean -f -d # remove untracked
git clean -f -x -d # CAUTION: as above but removes ignored files like config.
git clean -fxd :/ # CAUTION: as above, but cleans untracked and ignored files through the entire repo (without :/, the operation affects only the current directory)
这篇关于git:撤消所有工作目录更改,包括新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文