24

I'm getting this error when running "git stash"

Cannot save the current status

with no other information.

Why is that?

Simon Tran
  • 1,461
  • 1
  • 11
  • 28

10 Answers10

18

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

rm -f .git/refs/stash

That fixed it

pkamb
  • 33,281
  • 23
  • 160
  • 191
Simon Tran
  • 1,461
  • 1
  • 11
  • 28
  • 1
    I had to delete `.git/refs/stash.lock` as well. After that `git stash` started to work well. – Andrii Tykhonov Apr 13 '21 at 17:35
  • i got solution from your link, but the file your removed, not just that , my issue got resolve with this https://stackoverflow.com/a/19409320/4811421 answer from your link – Shreyan Mehta Jun 02 '21 at 07:58
12

In my case, .git/refs/stash was owned by root.

Simply running chown -R <user>:<group> .git (Linux) fixed it.

Note that you might only need to chown -R <user>:<group> .git/refs/stash, though.

Replace <user> and <group> with your user name and main group.

Francisco Puga
  • 23,869
  • 5
  • 48
  • 64
evanjs
  • 199
  • 2
  • 11
  • 1
    This was precisely my issue too. A precommit hook inside a docker container had changed the owner. – kaan_a Jun 17 '23 at 12:35
4

For me,

cd .git/
sudo chmod -R 777 *
sudo chown -R owner:owner *
git add . && git stash

Worked

sg28
  • 1,363
  • 9
  • 19
4

I solve this problem by git stash clear.

joe
  • 8,383
  • 13
  • 61
  • 109
2

You get this error sometime when you are in mid of a conflict. You will get more information if you check git status and see if you are in mid of a merge conflict resolution.

You can either abort the merge: If you don't want to consider your previous merge (you are sure and you would lose the history information associated with the merge), you can abort then using

git merge --abort

Or reset your git state to original HEAD:

git reset ORIG_HEAD

I hope it helps.

user
  • 867
  • 9
  • 21
  • "git merge --abort" gives me "fatal: There is no merge to abort (MERGE_HEAD missing).". If I reset to head, and change I single file to try to stash, I still get the same error – Simon Tran Jul 09 '19 at 20:42
1

In my case, I had Visual Studio using git and was trying to stash using the command line. Closing Visual Studio solved the problem.

LucaSC
  • 722
  • 1
  • 10
  • 19
0

This is an old question, but this may help Mac users.

If you are copying files from Time Machine manually, instead of restoring them through Time Machine, it'll add ACLs to everything, which can mess up your permissions.

For example, the section in this article that says "How to Fix Mac OS X File Permissions" shows that "everyone" has custom permissions, which messes it all up:

Bad permissions, from http://dreamlight.com/how-to-fix-mac-os-x-file-permissions

You need to remove the ACLs from those directories/files. This Super User answer goes into it, but here's the command:

sudo chmod -RN .

Then you can make sure your directories and files have the proper permissions. I use 750 for directories and 644 for files.

Ankit Bhatnagar
  • 745
  • 5
  • 16
0

I solved it in Windows by right clicking on the shortcut to Git Bash and choosing "Run as administrator" before I run git stash.

I can verify that running Git Fork as administrator also solves this problem if using Git Fork to stash, so there is a good chance it will solve it in other git tools such as Git for Windows or Sourcetree.

lala
  • 2,052
  • 6
  • 24
  • 33
0

Run this

git reset --mixed

and then

git stash

before pull.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
CoderTest
  • 35
  • 1
  • 6
0

I had the same problem because some files changed their permissions (in ubuntu). I fixed it by running the command git stash with "sudo"

sudo git stash

I hope you can fix the problem

direyes
  • 53
  • 4