In Git, once a branch named a already exists, you cannot create a/b. 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. git/refs/remotes/origin/branch then try again, as a few users reported that it works for them. Run the following command to optimize your current 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. Git has a built-in gc command to cleanup unnecessary files and optimize the local repository. 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. It seems in some cases these references can contain data Git cannot handle correctly. 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. The command will remove references to remote branches in the folder. Users across online forums have reported that the command below worked for them: git remote prune origin Git remote add origin :your-username/repo-name.git Prune remote origin Remove the remote from your local git repo: Origin :your-username/repo-name.git (push) Which will print out something like this: origin :your-username/repo-name.git (fetch) You can print it to the terminal using this command: If you don’t know how to do that, follow step-by-step instructions below.Ĭopy the SSH git URL of your existing remote. Quick fix : Remove and re-add remoteĪs 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. Now let’s go through possible solutions to make the “error: cannot lock ref” goes away. ! 70ea06a46f.2e4bfdb24f master -> origin/master (unable to update local ref) Code language: JavaScript ( javascript ) 9 (unable to update local ref) Code language: JavaScript ( javascript ) error: cannot lock ref 'refs/remotes/origin/test': is at c21593dc62042d39efc044f366579667e but expected 3d0e5b15fc558cd447fb475a8ecd999 Code language: JavaScript ( javascript ) > git pull origin masterĮrror: cannot lock ref 'refs/remotes/origin/master': is at 2e4bfdb24fd137a1d2e87bd480f283cf7001f19a but expected 70ea06a46fd4b38bdba9ab1d64f3fee0f63806a5 8 (unable to update local ref)Įrror: cannot lock ref 'refs/tags/v2.9': 'refs/tags' exists cannot create 'refs/tags/v2.9' Unable to create branch path https: //user: /myproject/info/įatal: git-http-push failed Code language: JavaScript ( javascript ) > git pullĮrror: cannot lock ref 'refs/tags/v2.8': 'refs/tags' exists cannot create 'refs/tags/v2.8' Below is a few of the outputs we’ve seen : C:\MyWorkStuff\Projects\Ruby\MyProject\>git push origin master “error: cannot lock ref” comes in many forms, often followed by addition information about what gone wrong. “error: cannot lock ref” simply means information in /refs are corrupted and Git cannot continue to create index.lock file. git directory to ensure that no other Git process takes place during the operation. Whenever you run an operation in Git, it creates index.lock file inside. They are the directories that contains information about each of your file in branches and tags. Look closer into /refs and you will see /heads and /tags inside. git is all kinds of information about branch, commit, submodule, etc.Ī typical. In order to understand why the reason behind “error: cannot lock ref”, first, you need to know how Git uses a locking mechanism internally.Įverything related to your working directory is placed in a single, hidden directory named. 6 Double check for confusing branch names Understanding Git locking mechanism
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |