Steve Bennett
Steve Bennett

Reputation: 126125

Can you retrieve a change from the index?

I ask only for my general Git education - I don't have any particular problem atm. I'm just curious. Say you do this:

vim foo.txt

...write some good doco...

git add foo.txt
rm foo.txt

Can it be retrieved? How?

Upvotes: 0

Views: 56

Answers (2)

DJ.
DJ.

Reputation: 6774

You can get the worspace file back by:

git checkout foo.txt

Upvotes: 0

Lily Ballard
Lily Ballard

Reputation: 185671

git checkout -- foo.txt

git checkout, when given a path, checks things out of the index (by default; it can be instructed to check things out from commits as well).

Upvotes: 2

Related Questions