How do I discard unstaged changes in Git?

我如何放弃工作副本中不在索引中的更改?


Another quicker way is:

git stash save --keep-index

Include --include-untracked if you'd want to be thorough about it.

After that, you can drop that stash with a git stash drop command if you like.


For a specific file use:

git checkout path/to/file/to/revert

For all unstaged files use:

git checkout -- .

Make sure to include the period at the end.


It seems like the complete solution is:

git clean -df
git checkout -- .

git clean removes all untracked files ( warning : while it won't delete ignored files mentioned directly in .gitignore, it may delete ignored files residing in folders ) and git checkout clears all unstaged changes.

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

上一篇: 参考 - 这个符号在PHP中的含义是什么?

下一篇: 我该如何放弃Git中未分配的更改?