H2ONaCl
H2ONaCl

Reputation: 11269

Undo unstaged modifications for a single file in git

How can I undo unstaged modifications to a single file? By unstaged, I mean git add has yet to be performed since the last checkout.

Upvotes: 3

Views: 369

Answers (2)

Tearsdontfalls
Tearsdontfalls

Reputation: 777

Like I already posted in the Comments before,

git checkout <filename>

is what you are looking for.

For more informations, see http://githowto.com/undoing_staged_changes , its a nice git tutorial.

Upvotes: 3

Tuxdude
Tuxdude

Reputation: 49473

This is the command you're looking for to back out your local unstaged changes.

WARNING: Any local changes in the file would be lost and the file would be replaced with the one from HEAD.

git checkout -- filename

Upvotes: 2

Related Questions