Tim
Tim

Reputation: 99428

Get back my changes in a working directory after reverting them by `git checkout -- myfile`

I was working in my working directory, without running git add and git commit yet.

Then I would like to see how things work before my changes, so I reverted my changes on two files by

git checkout -- myfile1
git checkout -- myfile2

Then i realized I would like to switch between before- and after-my-change, and learned that git stash can be used to save my changes in a stack and pop it out later.

Now since I revert everything in the working directory, is it possible to get back my changes and then use git stash to switch between before and after my changes?

Thanks.

Upvotes: 0

Views: 27

Answers (1)

torek
torek

Reputation: 488183

Git cannot help you here. Unless they were copied there from a Git commit (or the index), files in your work-tree are only in your work-tree; anything you do to them there, Git does not save until you git add them to copy them into Git's index.

Depending on your OS and other OS-specific items, you may be able to get the contents back from something other than Git, but that's all quite outside Git itself.

Upvotes: 1

Related Questions