-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
reference broken #3838
Comments
@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
This tells Git to go and fetch whatever it can find from the remote.
This ensures your local |
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, |
@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.
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: https://git-scm.com/download/win 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!
I downloaded Git and tried the steps above, but get this result:
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. **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
You can go to the menu and select
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 |
Thanks so much for the help! Unfortunately I'm still not having any success with the steps above.
If I try skipping to the next step I get this: ***EDIT: |
@cfandel I'm glad you were able to workaround the issue!
Git Bash has an |
Very helpful explanation - thank you! |
Hello again, I have been having this issue about once a month, and each time repairing it by following the steps described above, which has been working fine. "Commit failed - exit code 128 received, with output: 'fatal: cannot lock ref 'HEAD': unable to resolve reference 'refs/heads/master': reference broken" In Git Bash in the current repository, I tried: and get the following error: Could you recommend what the best solution would be? |
$ git commit -m "Commit-1" |
Same. The issue still persists, even after following the steps @shiftkey mentioned. |
The rest of the two steps returned errors too. I can not commit, even from VSCode. |
I could finally work around this weird issue. Came with a tradeoff. Apparently, by deleting the .git folder from the workspace solved a lot of errors. Afterwards, I could commit directly from the Github desktop, as well. Just that the repository name changed locally, and had to publish a new repo(a new name , because already existing name, gave errors) to the remote. Hope this helps. As you can see, previously the dir name was React-Ecomm-App, it changed to MERN-Stack-App , also another tradeoff was, I lost all the staged changes commit... |
@Dtech-Dbug it sounds like there may have been some corruption in your repository that was causing this issue (which is why a fresh repository got things working). In the future you can get some further diagnostic information by running the command |
@steveward Thanks for your response, Steve. ❤ Meanwhile, here is another way that could be helpful :
|
Corruptions, from my experience, mostly occur when the writing process gets stopped while trying to write. If you don't, then it might be some physical source of unexpected shut down. @Dtech-Dbug @cfandel I wonder how often do you guys experience power outages. Or maybe the machines get shut down by somebody forcefully? Nobody deserves to have such a struggle so often, it's inhumane working conditions. Try resolving this by adding a reserve power supply. Maybe a centralized server for remote working stations, located somewhere with more stable electricity, would solve this. |
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: