Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stashed some code but don't know which stash it is in - how to figure out?

Tags:

I wrote considerable code for a feature and stashed the changes in git.

After that I pushed several changes into the repository and did a git stash and apply multiple times (read over 100 times).

After almost 2 months I now want to retrieve the changes from git stash – but I cant find them no matter what.

Tried several git stash apply, git stash list, git stash list -p. Nothing works. I cant find those old stashed changes.

Wish I had taken a backup instead of trusting git to stash them...sigh...

Can anyone help?

like image 999
user811433 Avatar asked Jan 15 '14 06:01

user811433


1 Answers

Try this:

git stash list -p | grep 'diff --git' | grep <your file name> 

That will find your files in the list. It might take a while.

One thing: git stash apply does not discard a stash. After a successful apply, you should git stash drop so it dos not clutter your list. Personally, I apply the stash using git stash pop.

like image 163
Alex Siri Avatar answered Oct 07 '22 15:10

Alex Siri