Git pull error cannot lock ref

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. > git pull error: cannot

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.

> git pull
error: cannot lock ref 'refs/tags/v2.8': 'refs/tags' exists; cannot create 'refs/tags/v2.8'
From github.com:k3it/qsorder
 ! [new tag]         v2.8       -> v2.8  (unable to update local ref)
error: cannot lock ref 'refs/tags/v2.9': 'refs/tags' exists; cannot create 'refs/tags/v2.9'
 ! [new tag]         v2.9       -> v2.9  (unable to update local ref)

asked Apr 21, 2017 at 3:30

k3it's user avatar

1

Your Git is complaining that a reference (rather than a directory) named refs/tags exists. It’s not clear what would create that, but see if git rev-parse refs/tags produces a hash ID. If so, that reference needs to go away:

git update-ref -d refs/tags

after which git fetch should work.

If git rev-parse refs/tags fails (which it should—refs/tags itself should not be a valid name) then this is not the problem and it’s not clear what the actual problem is.

answered Apr 21, 2017 at 4:45

torek's user avatar

torektorek

427k53 gold badges591 silver badges733 bronze badges

3

Running

git remote prune origin

Worked for me. Not sure why this was the issue, but seems like there was a broken reference to a remote branch.

answered Feb 14, 2018 at 1:30

Xstatic's user avatar

XstaticXstatic

1,2431 gold badge10 silver badges14 bronze badges

1

git gc will solve it!

Cleanup unnecessary files and optimize the local repository
Link

answered Jun 10, 2021 at 9:03

Akshay Vijay Jain's user avatar

1

error: cannot lock ref ‘refs/tags/v2.8’: ‘refs/tags’ exists; cannot create ‘refs/tags/v2.8’
From github.com:k3it/qsorder

Try deleting your local tag v2.8 and v2.9 then pull again.

$ git tag -d v2.8 
$ git tag -d v2.9

$ git pull

If you want to delete all local tags by a command:

$ git tag | xargs git tag -d

answered Apr 21, 2017 at 3:33

Sajib Khan's user avatar

Sajib KhanSajib Khan

21.9k8 gold badges63 silver badges72 bronze badges

6

In my case, the following helped:

git fetch --prune origin
git pull

answered Apr 12, 2021 at 14:59

ellockie's user avatar

ellockieellockie

3,3346 gold badges40 silver badges41 bronze badges

This worked for me after all other answers didn’t

git update-ref --no-deref -d refs/remotes/origin/branch_name

answered Jul 19, 2022 at 20:34

Pants's user avatar

PantsPants

2,3951 gold badge17 silver badges32 bronze badges

First Solution ==>:let’s say you have branch called develop and you’re trying to create new branch called develop/updatefeature this will cause this error, that was my case so If you remove the develop word from the new branch (updatefeature)I think It should be solved the issue.

Second Solution ==>: use the below command in bash

git remote prune origin

answered Jun 4, 2021 at 17:53

Yazan Najjar's user avatar

Yazan NajjarYazan Najjar

1,59314 silver badges7 bronze badges

1

#!/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

answered Nov 23, 2017 at 16:19

Tomer Bar-Shlomo's user avatar

For a quick work around you can use

git push --delete origin 'v2.8'

git push --delete origin 'v2.9'

answered Sep 13, 2017 at 16:26

Shane Fast's user avatar

0

This is what I tried and it worked for me.

git remote prune origin

ascripter's user avatar

ascripter

5,40512 gold badges49 silver badges66 bronze badges

answered Nov 5, 2019 at 11:35

Krishna Jit's user avatar

I was trying to push (/dev/somechanges) and I have a remote branch (/dev) with the same prefix
when I choose a new name that is not starting with /dev it worked fine.

answered May 21, 2020 at 12:30

Melad's user avatar

MeladMelad

1,14414 silver badges17 bronze badges

For me, I tried git update-ref -d refs/tags and git remote prune origin but nothing worked.

My command was git checkout -b test/revert_code, so finally, I recognized that the problem is not the git, but my command itself. When I removed «test/«, it worked as normal. So my final command was git checkout -b revert_code.

Maybe this is just a rare case, but hope this help anyone who have tried all solutions above but hadn’t worked.

answered Jan 31 at 2:02

haptn's user avatar

haptnhaptn

1344 bronze badges

Do you want to understand what «error: cannot lock ref» in Git actually means and how to fix it?

Version control (VCS) has become a vital part of modern software development workflow. Many VCS system exists, but market research shows that Git is the most popular of all.

Before Git you would copy the entire repository to another directory and then by hand copy your changes to the correct repository. Now creating a branch takes about as long as it takes to type the command. Git scratched many itches, some of which we didn’t even realize until we know it.

Most of the time, Git handles most changes automatically and encourages users to integrate the changes every day or even more often. But sometimes, Git can pops out strange error which is pretty vague and hard to debug if you’re a beginner.

This article is going to show you the reason behind «error: cannot lock ref» in Git and how to fix the error quickly.

Understanding Git locking mechanism

In order to understand why the reason behind «error: cannot lock ref», first, you need to know how Git uses a locking mechanism internally.

Everything related to your working directory is placed in a single, hidden directory named .git. Inside .git is all kinds of information about branch, commit, submodule, etc.

A typical .git directory looks like this

.git/
    hooks/
    info/
    logs/
    objects/
    refs/
    HEAD
    config
    description
    index
    packed-refs

Look closer into /refs and you will see /heads and /tags inside. They are the directories that contains information about each of your file in branches and tags.

Whenever you run an operation in Git, it creates index.lock file inside .git directory to ensure that no other Git process takes place during the operation.

«error: cannot lock ref» simply means information in /refs are corrupted and Git cannot continue to create index.lock file.

What the error looks like

«error: cannot lock ref» comes in many forms, often followed by addition information about what gone wrong. Below is a few of the outputs we’ve seen :

C:MyWorkStuffProjectsRubyMyProject>git push origin master
Unable to create branch path https://user:[email protected]/myproject/info/
error: cannot lock existing info/refs
fatal: git-http-push failed
> git pull
error: cannot lock ref 'refs/tags/v2.8': 'refs/tags' exists; cannot create 'refs/tags/v2.8'
From github.com:k3it/qsorder
 ! [new tag]         v2.8       -> v2.8  (unable to update local ref)
error: cannot lock ref 'refs/tags/v2.9': 'refs/tags' exists; cannot create 'refs/tags/v2.9'
 ! [new tag]         v2.9       -> v2.9  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/test': is at c21593dc62042d39efc044f366579667e but expected 3d0e5b15fc558cd447fb475a8ecd999
> git pull origin master
From github.com:Microsoft/vscode
 * branch                  master     -> FETCH_HEAD
error: cannot lock ref 'refs/remotes/origin/master': is at 2e4bfdb24fd137a1d2e87bd480f283cf7001f19a but expected 70ea06a46fd4b38bdba9ab1d64f3fee0f63806a5
 ! 70ea06a46f..2e4bfdb24f  master     -> origin/master  (unable to update local ref)

Now let’s go through possible solutions to make the «error: cannot lock ref» goes away.

Quick fix : Remove and re-add remote

As all general computer-related advice said : When in doubt, restart! The quickest way you can get rid of «error: cannot lock ref» is to remove the remote so that you can add it again later.

If you don’t know how to do that, follow step-by-step instructions below.

  1. Copy the SSH git URL of your existing remote. You can print it to the terminal using this command:

    git remote -v

which will print out something like this:

 origin [email protected]:your-username/repo-name.git (fetch)
 origin [email protected]:your-username/repo-name.git (push)
  1. Remove the remote from your local git repo:

    git remote rm origin

  2. Add the remote back to your local repo:

    git remote add origin [email protected]:your-username/repo-name.git

Prune remote origin

Users across online forums have reported that the command below worked for them:

git remote prune origin

The command will remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remote, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

If you’re reluctant to try the command above, which I didn’t at first, you can run git remote prune origin --dry-run to see what happens before proceeding with the actual command.

Clean up and optimize local repository

Git has a built-in gc command to cleanup unnecessary files and optimize the local repository. The command do housekeeping tasks such as compressing file revisions to improve performance, removing unreachable objects which may have been created from prior invocations of git add, packing refs, pruning reflog, rerere metadata or stale working trees.

Run the following command to optimize your current repository.

git gc --prune=now

If it didn’t work, you can remove .git/logs/refs/remotes/origin/branch and .git/refs/remotes/origin/branch then try again, as a few users reported that it works for them.

Double check for confusing branch names

If you’re creating a new branch and none of the above solutions works for you, the next thing you can do is to verify that your existing branch names don’t conflict with the new one. In Git, once a branch named a already exists, you cannot create a/b. Likewise, if a/b exists, creating a/b/c branch is not possible.

Содержание

  1. “error: cannot lock ref” – what to do?
  2. Understanding Git locking mechanism
  3. What the error looks like
  4. Quick fix : Remove and re-add remote
  5. Prune remote origin
  6. Clean up and optimize local repository
  7. Double check for confusing branch names
  8. reference broken #3838
  9. Comments
  10. Error: Cannot lock ref ‘refs/remotes/origin/master’ #6121
  11. Comments
  12. Description
  13. Version
  14. Steps to Reproduce
  15. Expected(Blue Box) and Actual(Red Box) Behavior
  16. Additional Information

“error: cannot lock ref” – what to do?

Do you want to understand what «error: cannot lock ref» in Git actually means and how to fix it?

Version control (VCS) has become a vital part of modern software development workflow. Many VCS system exists, but market research shows that Git is the most popular of all.

Before Git you would copy the entire repository to another directory and then by hand copy your changes to the correct repository. Now creating a branch takes about as long as it takes to type the command. Git scratched many itches, some of which we didn’t even realize until we know it.

Most of the time, Git handles most changes automatically and encourages users to integrate the changes every day or even more often. But sometimes, Git can pops out strange error which is pretty vague and hard to debug if you’re a beginner.

This article is going to show you the reason behind «error: cannot lock ref» in Git and how to fix the error quickly.

Understanding Git locking mechanism

In order to understand why the reason behind «error: cannot lock ref», first, you need to know how Git uses a locking mechanism internally.

Everything related to your working directory is placed in a single, hidden directory named .git . Inside .git is all kinds of information about branch, commit, submodule, etc.

A typical .git directory looks like this

Look closer into /refs and you will see /heads and /tags inside. They are the directories that contains information about each of your file in branches and tags.

Whenever you run an operation in Git, it creates index.lock file inside .git directory to ensure that no other Git process takes place during the operation.

«error: cannot lock ref» simply means information in /refs are corrupted and Git cannot continue to create index.lock file.

What the error looks like

«error: cannot lock ref» comes in many forms, often followed by addition information about what gone wrong. Below is a few of the outputs we’ve seen :

Now let’s go through possible solutions to make the «error: cannot lock ref» goes away.

Quick fix : Remove and re-add remote

As all general computer-related advice said : When in doubt, restart! The quickest way you can get rid of «error: cannot lock ref» is to remove the remote so that you can add it again later.

If you don’t know how to do that, follow step-by-step instructions below.

Copy the SSH git URL of your existing remote. You can print it to the terminal using this command:

which will print out something like this:

Remove the remote from your local git repo:

git remote rm origin

Add the remote back to your local repo:

git remote add origin [email protected]:your-username/repo-name.git

Prune remote origin

Users across online forums have reported that the command below worked for them:

The command will remove references to remote branches in the folder .git/refs/remotes/origin . So this will not affect your local branches and it will not change anything remote, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

If you’re reluctant to try the command above, which I didn’t at first, you can run git remote prune origin —dry-run to see what happens before proceeding with the actual command.

Clean up and optimize local repository

Git has a built-in gc command to cleanup unnecessary files and optimize the local repository. The command do housekeeping tasks such as compressing file revisions to improve performance, removing unreachable objects which may have been created from prior invocations of git add, packing refs, pruning reflog, rerere metadata or stale working trees.

Run the following command to optimize your current repository.

If it didn’t work, you can remove .git/logs/refs/remotes/origin/branch and .git/refs/remotes/origin/branch then try again, as a few users reported that it works for them.

Double check for confusing branch names

If you’re creating a new branch and none of the above solutions works for you, the next thing you can do is to verify that your existing branch names don’t conflict with the new one. In Git, once a branch named a already exists, you cannot create a/b . Likewise, if a/b exists, creating a/b/c branch is not possible.

Источник

reference broken #3838

error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference ‘refs/remotes/origin/master’: reference broken
From https://github.com/herio5154/stargoon
! [new branch] master -> origin/master (unable to update local ref)

The text was updated successfully, but these errors were encountered:

@herio5154 thanks for the feedback! It looks like something with the underlying Git repository has broken, leaving it in an invalid state.

I think these steps should get you back to a happy place, but take a backup of your repository before running any of these commands, just in case.

I’ll explain the intent behind each step as we go along. This assumes using Git Bash, but if you are using a different shell let me know which and I’ll tweak it.

Git stores refs and other Git data on disk under the .git folder, and it looks like the value of whatever origin/master entry Git was tracking is now invalid. This will remove the file to hide it from Git locally.

This tells Git to go and fetch whatever it can find from the remote.

This ensures your local master is tracking whatever is currently on origin/master , which should put Git back into a happy place.

Closing this out due to inactivity. @herio5154 let us know if there’s anything else we can do to address the problem!

This actually worked for me too, thanks! ❤️

This worked for me too

Hello,
I’m having the same problem in GitHub Desktop, but I’m fairly new to using it and don’t have Git installed, only GitHub Desktop. Could you explain how to approach solving the problem assuming a little bit less pre-existing knowledge & without having Git installed? I’m working on Windows 10 and have the latest version of GitHub Desktop.
Thank you!

@cfandel are you seeing the same exact error output? If you can share the specific error message I can verify that the solution provided will work for you.

Could you explain how to approach solving the problem assuming a little bit less pre-existing knowledge & without having Git installed?

Unfortunately this problem is not resolvable within GitHub Desktop since it requires running a few specific Git commands. Since you do not have Git installed, you will need to download it from here:

Once you install Git you can launch it directly from GitHub Desktop and follow the steps @shiftkey provided. I would recommend making a backup of the repository, and let me know if you run into any specific issues.

The other workaround would be to clone a fresh copy of the repository, which will not have the broken references. If your local repository and remote repository are up-to-date with each other then that would be the easiest solution.

Thanks for the quick response!
The files on my computer (these are called the local files yes?) are up to date, but the files on GitHub are NOT up to date (because I made changes locally and then wasn’t able to push them).
In GitHub Desktop, the push button has changed to ‘Publish branch’ and I get the following error:

error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference ‘refs/remotes/origin/master’: reference broken From https://github.com/cfandel/gottesacker ! [new branch] master -> origin/master (unable to update local ref)

I downloaded Git and tried the steps above, but get this result:

$ rm.git/refs/remotes/origin/master bash: rm.git/refs/remotes/origin/master: No such file or directory

When you say clone a fresh copy of the repository, does that mean taking the copy on my computer and replacing everything currently on GitHub with the files I have, or vice-versa? If it means preserving the version on my computer, that’s a fine solution, but otherwise it will result in losing a bunch of work.
Also, in the long term, if this issue happens again, it would be best to know how to repair it without having to clone a fresh copy no?

**Note: I wasn’t able to see where to launch Git from GitHub Desktop? So I tried this in Git Bash launched from the Windows Search Bar.

@cfandel it looks like you may have missed a space between the rm (remove) command and the file path:

**Note: I wasn’t able to see where to launch Git from GitHub Desktop? So I tried this in Git Bash launched from the Windows Search Bar.

You can go to the menu and select File > Open in Command Prompt . That will launch CMD — if you would prefer to use Git Bash you can change this setting by going to File > Options > Advanced and choosing Git Bash from the Shell dropdown.

If it means preserving the version on my computer, that’s a fine solution, but otherwise it will result in losing a bunch of work.

In that case we will want to get things working with the local repository, since a fresh clone will not have your local changes.

@cfandel it may actually be that you were not in the correct directory when you ran the command — if you open the repository in the command line from within GitHub Desktop it will drop you right into the correct directory. If you open Git Bash separately it will launch into your User directory, and you will need to use cd /path/to/repository to change to the correct directory.

Thanks so much for the help!
I opened Command Prompt from GitHub Desktop (though it’s under the Repository menu not the File menu), and tried again. If I understand correctly, all Git commands run from Command Prompt have to be preceded by the word «git»? And if they are run from Git Bash, the command is exactly the same but without the preceding «git», but I need to make sure to be in the correct directory first?

Unfortunately I’m still not having any success with the steps above.
Here are the commands I tried and the results (note that I am now in the correct directory I think):

C:UsersChloeDocumentsGitHubgottesacker>rm .git/refs/remotes/origin/master
‘rm’ is not recognized as an internal or external command, operable program or batch file.
This means I need to tell Command Prompt that I want to use Git commands right?
So I tried adding a preceding «git»:
C:UsersChloeDocumentsGitHubgottesacker>git rm .git/refs/remotes/origin/master
And get this result:
fatal: pathspec ‘.git/refs/remotes/origin/master’ did not match any files

If I try skipping to the next step I get this:
C:UsersChloeDocumentsGitHubgottesacker>git fetch error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference ‘refs/remotes/origin/master’: reference broken From https://github.com/cfandel/gottesacker ! [new branch] master -> origin/master (unable to update local ref)

***EDIT:
I tried this exact same process, but by opening Git Bash from within GitHub Desktop, and it seems to have worked! However, I’m still not at all clear about why — what is the difference between doing it in Command Prompt and doing it in Git Bash?

@cfandel I’m glad you were able to workaround the issue!

‘rm’ is not recognized as an internal or external command, operable program or batch file.
This means I need to tell Command Prompt that I want to use Git commands right?

rm is a built-in program that’s part of most Unix shells. The equivalent command in Command Prompt is del but they accept different parameters, so be mindful of the shell you are using to run commands.

However, I’m still not at all clear about why — what is the difference between doing it in Command Prompt and doing it in Git Bash?

Git Bash has an rm included in it’s environment, so the command works fine there. git rm is a Git-specific command to remove files from within a Git repository, and isn’t a replacement for rm .

Источник

Error: Cannot lock ref ‘refs/remotes/origin/master’ #6121

I have some problem with my GitHub. I read similar questions and answers to them in many forums, but unfortunately nothing helped.

error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference
‘refs/remotes/origin/master’: reference broken
From https://github.com/arbuzzer/arbuzzer.github.io
! [new branch] master -> origin/master (unable to update local ref)

The text was updated successfully, but these errors were encountered:

Hi @arbuzzer, thanks for the report and sorry you’re having issues.

We ask that folks fill out the template so we can better understand your setup and what’s going on so we make the best use of the maintainers’ time. Here’s the template you need: https://github.com/desktop/desktop/issues/new?template=bug_report.md

Thanks for understanding and meeting us halfway! 😄

@arbuzzer It looks like there may be some underlying repository corruption that is causing this issue. Could you go to the file menu in GitHub Desktop and select Repository > Open in and run the command git fsck ? That should give some some more information about this error. Please share the full output of that command.

@arbuzzer It looks like there may be some underlying repository corruption that is causing this issue. Could you go to the file menu in GitHub Desktop and select Repository > Open in and run the command git fsck ? That should give some some more information about this error. Please share the full output of that command.

Hi @arbuzzer, thanks for the report and sorry you’re having issues.

We ask that folks fill out the template so we can better understand your setup and what’s going on so we make the best use of the maintainers’ time. Here’s the template you need: https://github.com/desktop/desktop/issues/new?template=bug_report.md

Thanks for understanding and meeting us halfway! 😄

Description

error: cannot lock ref ‘refs/remotes/origin/master’: unable to resolve reference
‘refs/remotes/origin/master’: reference broken
From https://github.com/arbuzzer/arbuzzer.github.io
! [new branch] master -> origin/master (unable to update local ref)

Version

*GitHub Desktop:

*Operating system:

Steps to Reproduce

  1. I read the whole topic on this site and none of the proposed solutions helped me. (https://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref)

Expected(Blue Box) and Actual(Red Box) Behavior


  1. 3.
    And so with every command that people offer.

Additional Information

Thanks for sharing that information @arbuzzer. A few other questions:

  • Based on the screenshot it looks like you are were running those commands in your root directory (i.e. C:UsersYour_User) — is that the correct location of this repository, or is it possibly in a different directory? If you are storing this repository in a different location you will need to run Git commands from within that directory that contains your repository.
  • Is this a repository that you just freshly cloned to your local machine using GitHub Desktop?

It would also be helpful if you could run the following two commands within the repository directory to provide more configuration information about your local repository:

git branch -a
git config -l —list

Please let me know the output of both of those commands

Thanks for sharing that information @arbuzzer. A few other questions:

  • Based on the screenshot it looks like you are were running those commands in your root directory (i.e. C:UsersYour_User) — is that the correct location of this repository, or is it possibly in a different directory? If you are storing this repository in a different location you will need to run Git commands from within that directory that contains your repository.
  • Is this a repository that you just freshly cloned to your local machine using GitHub Desktop?

It would also be helpful if you could run the following two commands within the repository directory to provide more configuration information about your local repository:

git branch -a
git config -l —list

Please let me know the output of both of those commands



Thanks for sharing that information @arbuzzer. A few other questions:

  • Based on the screenshot it looks like you are were running those commands in your root directory (i.e. C:UsersYour_User) — is that the correct location of this repository, or is it possibly in a different directory? If you are storing this repository in a different location you will need to run Git commands from within that directory that contains your repository.
  • Is this a repository that you just freshly cloned to your local machine using GitHub Desktop?

It would also be helpful if you could run the following two commands within the repository directory to provide more configuration information about your local repository:

git branch -a
git config -l —list

Please let me know the output of both of those commands

I did all the actions described on the forums again and that’s what I did. Expected(Blue Box) and Actual(Red Box) Behavior.

Источник

Skip to content

After cloning from remote git repository I made some changes, committed and tried to push or

Tried to pull latest code from remote repository but getting below error?

Errors with like error: cannot lock ref

error: cannot lock existing info/refs
fatal: git-http-push failed

This case regards already existing repository.

I’m using Windows. The detailed error was:

error: cannot lock existing info/refs
fatal: git-http-push failed

git pull error: cannot lock refs, cannot lock ref refs is at but expected, how to fix?

Just run this command

git remote prune origin

This will do is remove references to remote branches in the folder .git/refs/remotes/origin.

So this will not affect your local branches and it will not change anything remotely, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

“git pull error: cannot lock refs, cannot lock ref refs is at but expected” solution is very simple for this git error. Just run this command:

git remote prune origin

What this command will do?
This will do is remove references to remote branches in the folder .git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remotely, but it will update the local references you have to remote branches. It seems in some cases these references can contain data Git cannot handle correctly.

This should ideally work, if not working, checkout repository again.

  • If this doesn’t work, you can try deleting that branch from local and checkout again.

Also Read: Microservices Interview Questions
could not get lock /var/lib/dpkg/lock | resource temporarily unavailable

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Git public key error
  • Git needs merge error you need to resolve your current index first
  • Git merge error the following untracked working tree files would be overwritten by merge
  • Git lfs smudge error
  • Git lfs error downloading object

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии