tinOfBeans
tinOfBeans

Reputation: 737

Anyway of restoring local changes before pull

I was working on some files locally and was behind the master branch. So before continuing, I pulled so I can work on these files while not being too far behind the master branch (I hadn't committed as the code I was working on was not finished).

So I was told a certain file would be changed if I pulled, so I should commit first or stash (standard stuff so far).

So I used git stash, Then pulled. Sure enough, the file I was warned about did change but my other (really important) file was also changed and I lost a lot of work.

How can I get this file back to what it was before my pull/stash? I have tried git stash apply, git reset Head x. I can only seem to go back to previous commits but cannot recover the work that was done just before the stash

Any ideas?

Upvotes: 0

Views: 68

Answers (1)

Vampire
Vampire

Reputation: 38619

If you stashed your changes, the changes are on the stash stack. If you did not, they are most probably lost. (One of the few ways to loose work with Git)
Look at git stash list how many stashes you have on the stack.
Look at their diffs with git diff stash@{x}^! to see if your work is part of that particular stash.
If you found the right stash apply its changes.
If not, you are probably lost if you do not use some IDE that tracks a local history of all changes to all edited files like IntelliJ IDEA.

Upvotes: 1

Related Questions