Alex Rivera | Logout

How do I discard unstaged changes in Git?

Asked 2008-09-09T19:33:59.133
6478

How do I discard changes in my working copy that are not in the index?

Edit
Report

2 Answers

2327

It seems like the complete solution is:

git clean -df
git checkout -- .

WARNING: while it won't delete ignored files mentioned directly in .gitignore, git clean -df may delete ignored files residing in folders.

git clean removes all untracked files and git checkout clears all unstaged changes.

answered 2012-08-29T18:28:04.550
408

This checks out the current index for the current directory, throwing away all changes in files from the current directory downwards.

git checkout .

or this which checks out all files from the index, overwriting working tree files.

git checkout-index -a -f
answered 2009-06-20T10:28:04.730

Your Answer