如何从工作目录中删除所有更改,包括新的未跟踪文件。我知道这样git checkout -f做,但它不会删除自上次提交以来创建的新的未跟踪文件。
git checkout -f
有人知道怎么做吗?
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)
要事先查看将要删除的内容,而不是实际删除它,请使用-n标志(这基本上是一个测试运行)。当您准备好实际删除时,请删除该-n标志:
-n
git clean -nfd