Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git stash fails 'error: unable to resolve reference refs/stash: No such file or directory'

Tags:

git

git-stash

Git pull command is working fine, but git stash is giving the following error:

$git stash
error: unable to resolve reference refs/stash: No such file or directory
fatal: Cannot lock the ref 'refs/stash'.
Cannot save the current status

How do i resolve this so that i don't loose my changes?

like image 795
skadoosh Avatar asked Aug 28 '13 05:08

skadoosh


3 Answers

I was having a very similar issue, after a corrupted filesystem.

The solution was to remove the file or directory at .git/logs/refs/stash

After deleting the file or directory, please use git stash to create a new ref, and that's all.

This will delete any stash you might have, so please be careful.

git stash
error: refs/stash does not point to a valid object!
rm -r .git/logs/refs/stash
git stash
Saved working directory and index state WIP on master: e1d74d8 fixing get_thumbnail_list
like image 168
Neoecos Avatar answered Nov 13 '22 00:11

Neoecos


I had to delete following file also to get it working.

rm -f .git/refs/stash
like image 18
Eržika Iťák Avatar answered Nov 12 '22 23:11

Eržika Iťák


You can remove the stash and add new stash folder if the problem still remained after remove the stash:

rm -r .git/logs/refs/stash

mkdir .git/logs/refs/stash

like image 2
ninjahoahong Avatar answered Nov 12 '22 23:11

ninjahoahong