17

git pull is giving this error:

$ git pull error: refs/stash does not point to a valid object! error: refs/stash does not point to a valid object! error: refs/stash does not point to a valid object! error: refs/stash does not point to a valid object! Current branch mybranch is up to date. 

I have tried this solution but it doesn't work for me. Updated info:

$ GIT_TRACE=1 git pull trace: exec: 'git-pull' trace: run_command: 'git-pull' trace: built-in: git 'rev-parse' '--git-dir' trace: built-in: git 'rev-parse' '--is-bare-repository' trace: built-in: git 'rev-parse' '--show-toplevel' trace: built-in: git 'ls-files' '-u' trace: built-in: git 'symbolic-ref' '-q' 'HEAD' trace: built-in: git 'config' '--bool' 'branch.mybranch.rebase' trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD' trace: built-in: git 'rev-parse' '--verify' 'HEAD' trace: built-in: git 'update-index' '-q' '--ignore-submodules' '--refresh' trace: built-in: git 'diff-files' '--quiet' '--ignore-submodules' trace: built-in: git 'diff-index' '--cached' '--quiet' '--ignore-submodules' 'HEAD' '--' trace: built-in: git 'rev-parse' '-q' '--git-dir' trace: built-in: git 'rev-parse' '-q' '--verify' 'refs/remotes/origin/mybranch' trace: built-in: git 'merge-base' '53512e9ce3faa7c78b6d5d7ba1a63e56b5a42a11' 'refs/heads/mybranch' trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD' trace: built-in: git 'fetch' '--update-head-ok' error: refs/stash does not point to a valid object! trace: run_command: 'ssh' 'git@git-master' 'git-upload-pack '\''function-test'\''' error: refs/stash does not point to a valid object! trace: run_command: 'rev-list' '--verify-objects' '--stdin' '--not' '--all' '--quiet' trace: run_command: 'rev-list' '--verify-objects' '--stdin' '--not' '--all' trace: exec: 'git' 'rev-list' '--verify-objects' '--stdin' '--not' '--all' trace: built-in: git 'rev-list' '--verify-objects' '--stdin' '--not' '--all' error: refs/stash does not point to a valid object! error: refs/stash does not point to a valid object! trace:... 
4
  • Not sure if this will help. But try git remote prune origin Commented Dec 18, 2013 at 16:49
  • 1
    please do $ GIT_TRACE=1 git pull and update your question with the actual refspec being used to call git fetch (the first thing git pull does). Commented Dec 18, 2013 at 17:26
  • @Vimsha: $ git remote prune origin returns error: refs/stash does not point to a valid object! Commented Dec 19, 2013 at 9:35
  • git remote prune origin worked for me! Commented Mar 27, 2016 at 10:24

4 Answers 4

54

The simplest thing would be to completely remove your stash. Note that you’ll need to remove two files - not one file, as outlined in the linked solution:

rm .git/refs/stash .git/logs/refs/stash 
Sign up to request clarification or add additional context in comments.

4 Comments

rm .git/refs/... works to me, thank you @mockinterface.
had to run git stash after that and errors vanished
I ended up doing a text search through my entire .git directory and removing all references.
I'm on Windows with git-gui 0.21 and when I went to menu Repository -> Visualize master's history, it showed the error, but I did this and the message it's gone, hope will nevershow again
1

I just ran into this error. Two servers were pulling a clone from the same source; only one of them gave this error. So I dug deeper.

Git's release notes for version 1.8.5.5 state:

  • "git clone" would fail to clone from a repository that has a ref directly under "refs/", e.g. "refs/stash", because different validation paths do different things on such a refname. Loosen the client side's validation to allow such a ref.

I found that one of the servers was using Git 1.7.1 and the other was using Git 1.8.5.6.

It's worth noting that the fetch command would fail as well, though not explicitly mentioned in the release notes above.


In my particular case I also found that the server with Git 1.7.1 actually had the later Git as well, but it was later in the PATH environment variable.

It may be of interest that when I ran git fetch using the later version, the clone thereafter worked even with the older version.


The simplest solution is just to upgrade Git to version 1.8.5.5 or later.

Or, of course, drop the stash, but then your clone will break again next time someone makes a stash.

Comments

1

I faced a similar issue but while doing go build or go mod tidy or go run. All the commands were giving me the same errors,

'error: refs/stash does not point to a valid object!'

I tried many things as below.

  1. git remote prune origin
  2. git stash
  3. rm .git/refs/stash .git/logs/refs/stash

Nothing worked for me. Finally, I deleted all the cache present in my system under path $GOPATH/go/pkg/mod/cache/, and I was able to resolve the issues.

Comments

1

I tried all of the recommended solutions, but nothing fixed it. What fixed it for me at the end was pretty simple:

# Made a small change in a code-file with vim # stash'ed it then git stash # got it back git stash pop # reverted my small change git checkout . # finish, no more error git pull 

That might not work for everyone, and it might not work without following other fixes made earlier in here. But its worth a try.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.