Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot lock ref 'refs/remotes/origin/master'

Tags:

I always got cannot lock ref 'refs/remotes/origin/master' when I execute git pull first time if there are some updates.

The full console log is belows.

D:\code\react-native\expo-multi-screen-starter>git pull
error: cannot lock ref 'refs/remotes/origin/master': is at b2459b4d5af42622cba55f9fe47ccd14fbd879bc but expected 76f11048c866cfe3e6570eaacf90db3cb7732723
From github.com:liudonghua123/expo-multi-screen-starter
 ! 76f1104..b2459b4  master     -> origin/master  (unable to update local ref)

D:\code\react-native\expo-multi-screen-starter>git pull
 App.js                                          | 19 ++++-----
 src/navigation/AuthStack.js                     | 14 +++++++
 src/navigation/RootNavigator.js                 | 22 ++++++++++
 src/navigation/TabNavigator.js                  |  4 +-
 src/screens/AuthLoadingScreen.js                | 35 ++++++++++++++++
 src/screens/HomeScreen.js                       | 19 +++++++++
 src/screens/{LoginScreen.js => SignInScreen.js} | 54 ++++++++++++++++++++++---
 7 files changed, 147 insertions(+), 20 deletions(-)
 create mode 100644 src/navigation/AuthStack.js
 create mode 100644 src/navigation/RootNavigator.js
 create mode 100644 src/screens/AuthLoadingScreen.js
 rename src/screens/{LoginScreen.js => SignInScreen.js} (61%)

D:\code\react-native\expo-multi-screen-starter>
like image 294
Donghua Liu Avatar asked Sep 27 '19 00:09

Donghua Liu


People also ask

How do I fix error Cannot lock ref?

Update local repository We need to remove branches that are no longer in the remote repository. Execute the following command. It removes all branches from the local repository that have gone from the remote repository. Try to execute git pull or git fetch .

How do I fix broken references in git?

Solution. Unsure the root cause of the "reference broken". To fix it, delete this file . git/refs/remotes/origin/master , and git fetch to retrieve it back.

What is fetch in git?

Git fetch summary In review, git fetch is a primary command used to download contents from a remote repository. git fetch is used in conjunction with git remote , git branch , git checkout , and git reset to update a local repository to the state of a remote.


1 Answers

You need to update the reference using following Git command on Git bash:

$ git update-ref -d refs/remotes/origin/[locked branch name]

then pull using $git pull

[locked branch name] is the name of the branch that the error is happening because of mismatch of commit Ids.

like image 151
Sanjay Gupta Avatar answered Jan 02 '23 11:01

Sanjay Gupta