Error: unable to block ref .. 'refs / tags' exists; can't create 'refs / tags /

I get a weird error β€œcan't block ref” when trying to pull changes from github. I tried git gc and looked for similar errors, but could not find a solution.

> git pull error: cannot lock ref 'refs/tags/v2.8': 'refs/tags' exists; cannot create 'refs/tags/v2.8' From github.com:k3it/qsorder ! [new tag] v2.8 -> v2.8 (unable to update local ref) error: cannot lock ref 'refs/tags/v2.9': 'refs/tags' exists; cannot create 'refs/tags/v2.9' ! [new tag] v2.9 -> v2.9 (unable to update local ref) 
+22
git github
source share
6 answers

Your Git complains that there is a link (not a directory) named refs/tags . It is not clear what to create this, but look if git rev-parse refs/tags creates a hash identifier. If so, this link should disappear:

 git update-ref -d refs/tags 

after which git fetch should work.

If git rev-parse refs/tags fails (which should be - refs/tags should not be the correct name), then this is not a problem, and it is not clear what the actual problem is.

+54
source share

Performance

 git remote prune origin 

Worked for me. Not sure why this was a problem, but it looks like there was an incorrect link to the remote branch.

+27
source share

error: cannot block ref 'refs / tags / v2.8': 'refs / tags' exists; can't create 'refs / tags / v2.8' from github.com:k3it/qsorder

Try removing the local tag v2.8 and v2.9 , then click again.

 $ git tag -d v2.8 $ git tag -d v2.9 $ git pull 

If you want to remove all local tags with the command:

 $ git tag | xargs git tag -d 
+1
source share
 #!/usr/bin/env bash echo "update-ref delete refs/tags" log="git-update-ref-errors.log" script="./git-update-ref-exist-tags-delete.sh" git_command="git update-ref -d refs/tags" echo "log errors from ${git_command} to ${log}" ${git_command} 2>&1 | > ${log} echo "show errors to ${log}" cat ${log} echo create ${script} touch ${script} echo "add execute (+x) permissions to ${script}" chmod +x ${script} echo "generate ${script} from errors log ${log}" ${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script} echo "execute ${script}" ${script} echo fetch log="git-fetch-errors.log" script="./git-fetch-exist-tags-delete.sh" git_command="git fetch" echo "log errors from ${git_command} to ${log}" ${git_command} 2>&1 | > ${log} echo "show errors from ${log}" cat ${log} echo create ${script} touch ${script} echo "add execute (+x) permissions to ${script}" chmod +x ${script} echo "generate ${script} from errors log ${log}" ${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script} echo "execute ${script}" ${script} git fetch echo pull log="git-pull-errors.log" script="./git-pull-exist-tags-delete.sh" git_command="git pull" echo "log errors from ${git_command} to ${log}" ${git_command} 2>&1 | > ${log} echo "show errors from ${log}" cat ${log} echo create ${script} touch ${script} echo "add execute (+x) permissions to ${script}" chmod +x ${script} echo "generate ${script} from errors log ${log}" ${git_command} 2>&1 | grep 'exists' | sed -n "s:.*\: 'refs/tags/\(.*\)' exists;.*:git tag -d '\1':p" >> ${script} echo "execute ${script}" ${script} git pull 

The script above will log errors in XXX-errors.log and fix them by creating and running XXX-exist-tags-delete.sh automatically from XXX-errors.log using the following commands:

  • git update-ref -d refs / tags
  • git fetch
  • git pull
+1
source share

For quick work you can use

git push --delete origin 'v2.8'

git push --delete origin 'v2.9'

0
source share

This topic may also be useful.

git push: links / headers / my / child branches exist, cannot create

If you have an existing branch "a" and you are trying to create something like "a / something else"

0
source share

All Articles