hard HEAD leaves untracked files behind

When I run git reset --hard HEAD , it's supposed to reset to a pristine version of what you pulled, as I understand it. Unfortunately, it leaves files lying around, as a git status shows a big list of untracked files.

How do you tell git "Just bring it back to EXACTLY what was in the last pull, nothing more, nothing less"?


你必须使用git clean -f -d来删除工作副本中未跟踪的文件和目录。


If you have files you still want to keep:

git clean -di will do an interactive clean which allows you to only delete the files/dirs you don't want anymore.


git reset --hard && git clean -dfx

or, zsh provides a 'gpristine' alias:

alias gpristine='git reset --hard && git clean -dfx'

Which is really handy

链接地址: http://www.djcxy.com/p/3280.html

上一篇: git命令将文件夹移动到另一个文件夹中

下一篇: 硬头部留下未跟踪的文件