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 all unstaged files use:

git checkout -- .

For a specific file use:

git checkout path/to/file/to/revert

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/3978.html

上一篇: 在App Engine上做一个大量的db.delete,而不用吃CPU

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