16

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:...
Community
  • 1
  • 1
Jaime M.
  • 3,613
  • 5
  • 32
  • 35

4 Answers4

52

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
mockinterface
  • 14,452
  • 5
  • 28
  • 49
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.

Wildcard
  • 1,302
  • 2
  • 20
  • 42
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.

bandanh
  • 533
  • 4
  • 20
0

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.

yogesh_desai
  • 449
  • 9
  • 21