1. error: some local refs could not be updated
An error display
The following error occurs when using Git pull
error: cannot lock ref 'refs/remotes/origin/ a branch ': 'refs/remotes/origin/ a branch ' exists; cannot create 'refs/remotes/origin/ a branch '
error: some local refs could not be updated
Copy the code
But let’s use it insteadgit pull origin develop
It was successful
Again we usegit pull
“, but the following error appears
Cause analysis,
When using Git pull, it was found that the refs of other branches tracked in the refs directory of the.git folder in the project were different from the refs of the corresponding branch in the remote repository, so the pull failed.
- A colleague forced this branch, resulting in the overwriting of the branch in the remote warehouse. However, our local warehouse refs will be inconsistent with the branch in the remote warehouse, resulting in failure
- Git branches are case insensitive. If a colleague deletes his own branch in the remote repository and creates another branch with the same name, the pull will fail
The solution
Method one: actually abovegit pull
An error has been reported indicating a resolution
error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches
Copy the code
So, we executegit remote prune origin
Have a try
This prune is a direct Git pull.
Method 2: Delete problematic refs
- Locate the error refs file in the refs directory under the.git folder and delete it
- use
$git update-ref -d refs/remotes/origin/refs