error: cannot lock ref.. 'refs/tags' exists; cannot create 'refs/tags/

前端 未结 7 899
野性不改
野性不改 2021-01-31 02:10

I\'m getting a strange \"cannot lock ref\" error when trying to pull changes from github. I\'ve tried git gc, and looked around for similar errors but can\'t find a solution.

相关标签:
7条回答
  • 2021-01-31 02:59
    #!/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 to XXX-errors.log and fix them by generating and running a XXX-exist-tags-delete.sh automatically from the XXX-errors.log using the following commands:

    1. git update-ref -d refs/tags
    2. git fetch
    3. git pull
    0 讨论(0)
提交回复
热议问题