Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arbuzzer opened this issue Nov 7, 2018 · 31 comments · Fixed by #6141
Closed

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

arbuzzer opened this issue Nov 7, 2018 · 31 comments · Fixed by #6141
Assignees

Comments

@arbuzzer
Copy link

arbuzzer commented Nov 7, 2018

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)

@arbuzzer arbuzzer changed the title Error: Cannot lock ref ... Error: Cannot lock ref 'refs/remotes/origin/master' Nov 7, 2018
@billygriffin
Copy link
Contributor

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! 😄

@billygriffin billygriffin added the more-info-needed The submitter needs to provide more information about the issue label Nov 7, 2018
@steveward
Copy link
Member

@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 <your_default_command_line_application> 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
Copy link
Author

arbuzzer commented Nov 7, 2018

@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 <your_default_command_line_application> and run the command git fsck? That should give some some more information about this error. Please share the full output of that command.

image

@arbuzzer
Copy link
Author

arbuzzer commented Nov 7, 2018

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:
image

*Operating system:
image

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. image
  2. image
    3.image
    And so with every command that people offer.

Additional Information

Profile-20181107T180828.zip

Logs

2018-11-07.desktop.production.log
2018-10-03.desktop.production.log
2018-10-02.desktop.production.log
2018-09-11.desktop.production.log
2018-09-10.desktop.production.log
2018-09-07.desktop.production.log
2018-09-05.desktop.production.log
2018-09-04.desktop.production.log
2018-09-03.desktop.production.log
2018-09-01.desktop.production.log

@steveward
Copy link
Member

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:\Users\Your_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

@arbuzzer
Copy link
Author

arbuzzer commented Nov 7, 2018

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:\Users\Your_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

image
image
image

@arbuzzer
Copy link
Author

arbuzzer commented Nov 7, 2018

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:\Users\Your_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.

image
image
image

@steveward
Copy link
Member

Thanks @arbuzzer. Try running the command git fetch --all to grab the remote origin/master branch again. That should hopefully fix this issue.

@arbuzzer
Copy link
Author

arbuzzer commented Nov 8, 2018

Спасибо @arbuzzer . Попробуйте запустить команду, git fetch --allчтобы origin/masterснова захватить удаленную ветку. Это, надо надеяться, исправить эту проблему.

image

@arbuzzer
Copy link
Author

arbuzzer commented Nov 8, 2018

Thanks @arbuzzer. Try running the command git fetch --all to grab the remote origin/master branch again. That should hopefully fix this issue.

Maybe it will help me to reinstall the system, or is it easier for me to create a new account? It is just important for me to use this application.

@steveward
Copy link
Member

@arbuzzer apologies -- I think we need to clean things up before running that command. Try these steps:

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

Let me know if that doesn't get things working.

@arbuzzer
Copy link
Author

arbuzzer commented Nov 8, 2018

@arbuzzer apologies -- I think we need to clean things up before running that command. Try these steps:

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

Let me know if that doesn't get things working.

It doesn't work :(
image

@steveward
Copy link
Member

@arbuzzer sorry about that -- you will need to run del .git/refs/remotes/origin/master since you are using the command prompt.

Maybe it will help me to reinstall the system, or is it easier for me to create a new account? It is just important for me to use this application.

If you would like you can also perform a fresh clone of the repository to GitHub Desktop -- a fresh clone will not have the issues you are encountering.

@shiftkey
Copy link
Member

shiftkey commented Nov 9, 2018

Repository fixes aside, I think #6141 here should prevent us from ending up in this situation again

@shiftkey shiftkey self-assigned this Nov 9, 2018
@arbuzzer
Copy link
Author

arbuzzer commented Nov 9, 2018

@arbuzzer сожалеет об этом - вам нужно будет запускать del .git/refs/remotes/origin/masterс тех пор, как вы используете командную строку.

Может быть, это поможет мне переустановить систему, или мне легче создать новую учетную запись? Для меня просто важно использовать это приложение.

Если вы хотите, чтобы вы также могли использовать новый клон репозитория для GitHub Desktop - новый клон не будет иметь проблем, с которыми вы сталкиваетесь.

image

@billygriffin billygriffin removed the more-info-needed The submitter needs to provide more information about the issue label Nov 14, 2018
@steveward
Copy link
Member

Sorry for the delay in getting back to you @arbuzzer. I'm not sure why the refs directory would not exist unless it was deleted. If you navigate to the GitHub\arbuzzer.github.io\.git\refs in File Explorer do you see anything there?

@shiftkey
Copy link
Member

Closing this out due to inactivity.

@arbuzzer if you're able to answer @steveward's question in the previous comment we're happy to revisit it.

@Ngwind
Copy link

Ngwind commented Mar 30, 2019

nice!this solved my problem

@arpitgupta19
Copy link

This worked for me :
git remote prune origin

@xiye520
Copy link

xiye520 commented Dec 4, 2019

git remote prune origin
This worked for me too!

@donprecious
Copy link

Try

$ git gc --prune=now
$ git remote prune origin

cleaning-up your local repository with:

@sugoireed
Copy link

After searching constantly, this is the solution that worked for me which entails unsetting/removing the Upstream

 git branch --unset-upstream

@briancalma
Copy link

git branch --set-upstream-to=origin/master

It worked like a charm! Thanks

@richierich25
Copy link

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

--> This worked for me magically.

@Dzone1658
Copy link

git fetch --all
git branch --set-upstream-to=origin/master

/* This one works for me */
thanks a lot.

@rishabh-mmc
Copy link

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

--> This worked for me magically.

@richierich25 worked for me too
thanks

@BellatrixLeStranger
Copy link

I had a similar issue running VSCode on Windows 10 and trying to commit changes or push. However what solved it for me was changing my controlled folder access in Windows settings which was preventing git from creating the .lock files locally.

@mkkmail
Copy link

mkkmail commented Dec 14, 2020

@arbuzzer apologies -- I think we need to clean things up before running that command. Try these steps:

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

Let me know if that doesn't get things working.

This worked for me. Thanks!

@PETEROLO291
Copy link

None of the previous methods worked for me, so what I did was make a copy of the folder, delete the folder, go to GitHub Desktop, clone the repository, paste the files that I had modified that I couldn't upload and that's it.

@AshutoshSajan
Copy link

@arbuzzer apologies -- I think we need to clean things up before running that command. Try these steps:

rm .git/refs/remotes/origin/master
git fetch
git branch --set-upstream-to=origin/master

Let me know if that doesn't get things working.

thank you

@CopyBug
Copy link

CopyBug commented Oct 21, 2021

@arbuzzer道歉——我认为我们需要在运行该命令之前清理一下。尝试以下步骤:
rm .git/refs/remotes/origin/master
git fetch
`git branch --set-upstream-to=origin/maste
谢谢你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.