The accepted solution provides details only about how OP got around the issue and it is not a definitive answer.
For the sake of people like me who end up here from Google, Here is the solution that actually works.
Lets say, if the error message looks like below,
error: cannot lock ref 'refs/remotes/origin/angular_removal': unable to resolve reference 'refs/remotes/origin/angular_removal': reference broken
Here, the offending element is a corrupted file named refs/remotes/origin/angular_removal
which resides in the .git
hidden folder.
Inorder to fix this, run the following commands under your repository root directory.
rm .git/refs/remotes/origin/angular_removal
git fsck
The first command alone should fix the issue as git
tries to reinitialize the missing references.
The command git fsck
is to there just to check if the repository is in good health.
NOTE : The
ref
file would be of different for others. So make sure
you are using theref
file name from the error message that you got.**