Skip to content

Instantly share code, notes, and snippets.

@otengkwame
Forked from lordlycastle/update_refs failed.sh
Created October 6, 2022 12:34
Show Gist options
  • Save otengkwame/68a437161a3d3768fe9eea93d4e885b0 to your computer and use it in GitHub Desktop.
Save otengkwame/68a437161a3d3768fe9eea93d4e885b0 to your computer and use it in GitHub Desktop.
When you get update_ref failed for ref error in git.
# Rename from 'C:/Users/Repos/phishfoodvr/.git/refs/remotes/origin/CHA/main.lock' to 'C:/Users/Repos/phishfoodvr/.git/refs/remotes/origin/CHA/main' failed. Should I try again? (y/n) n
# error: update_ref failed for ref 'refs/remotes/origin/CHA/main': couldn't set 'refs/remotes/origin/CHA/main'
$ cd $(git rev-parse --show-toplevel) # if necessary
$ rm -rf .git/refs/remotes/origin # remove all origin/*
$ mkdir .git/refs/remotes/origin # create empty origin/
$ git fetch origin # repopulate origin/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment