How to resolve: git push remote: error: cannot lock ref .... /refs/head/develop.lock exists

Joe Dahl-Fisher February 3, 2022

I'm struggling to solve an issues with one of my repositories. It started with a failed push from sourcetree, on attempting to push it again, or to run it in the shell, I am given this error:

emote: error: cannot lock ref 'refs/heads/develop': Unable to create '..../refs/heads/develop.lock': File exists.
remote:
remote: Another git process seems to be running in this repository, e.g.
remote: an editor opened by 'git commit'. Please make sure all processes
remote: are terminated then try again. If it still fails, a git process
remote: may have crashed in this repository earlier:
remote: remove the file manually to continue.

But I don't know how I can access the remote to delete the file? 

I can see others on here with similar problems but I didn't find a resolution...

 

UPDATE: 

I can still work with the repository in other ways - I've branched develop to a temporary branch for now.

Is my best bet is to delete the remote branch and push again? 

 

UPDATE TWO:

For future reference: Issues like this require access to the remote repo to resolve properly, so it requires support from Atlassian. 

For free plan users (like me) the best way to get that support is via this community board.

 

Thanks everyone!

 

3 answers

1 accepted

1 vote
Answer accepted
Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 4, 2022

Hi, @Joe Dahl-Fisher, welcome to the community! 

As we will need to access the repository to remove this lock file, I went ahead and created an internal ticket for you using the email of your community account, so you don't have to share this information here. 

You should have received an email with a link to the support ticket. Just in case you haven't received it, please feel free to let me know and I can post the ticket URL here. The ticket will be visible only to you and Atlassian staff, no one else can view its contents even if they have the URL.

Please let me know if you have any questions.

Kind regards,
Caroline

Joe Dahl-Fisher February 5, 2022

Thanks Caroline, I've been in contact with support and the problem is now resolved.

Like Caroline R likes this
Erik_Lopez October 11, 2022

I am getting this same issue now. Who can I contact for support?

1 vote
sonalilotankar October 8, 2022

Soln:

Step 1: remove mentioned reference

rm .git/refs/heads/develop

Step 2: git fetch

Step 3: git pull

 

 

cameron May 3, 2023

This does not work. Please don't submit false solutions stating they "will work 100%" as it has the potential to ruin some peoples working environment.

 

sonalilotankar May 3, 2023

Hey, I've updated the comments.

But in my case, whenever i faced this issue i used to follow above mentioned steps and it works in my case. 

Apologies..

Joaquim Monteiro June 27, 2023

This solution was the only one that worked for me, just you have to update the path to target your affected reference. also note the '.git'

thanks mate.

0 votes
Vishwas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2022

Hey @Joe Dahl-Fisher 

Welcome to Atlassian Community !!

Try running below command in git bash inside that repository folder.

First one shows what happens to the repo before doing an actual command which is second one.

git remote prune origin --dry-run
git remote prune origin

 Let me know how it goes.

 

Regards,

Vishwas

Joe Dahl-Fisher February 3, 2022

Hey, thanks for getting back to me. No luck unfortunately! The command doesn't seem to find anything to prune.

Vishwas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2022

Can you send me a screenshot so that i can understand better.

Also did you do git gc ? that was another method to fix.

Joe Dahl-Fisher February 4, 2022

Here is the output from my shell:
joe@Joes-MacBook-Pro maya_utils % git remote prune origin --dry-run
joe@Joes-MacBook-Pro maya_utils % git remote prune origin
joe@Joes-MacBook-Pro maya_utils % git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: error: cannot lock ref 'refs/heads/develop': Unable to create '...././refs/heads/develop.lock': File exists.

remote:
remote: Another git process seems to be running in this repository, e.g.
remote: an editor opened by 'git commit'. Please make sure all processes
remote: are terminated then try again. If it still fails, a git process
remote: may have crashed in this repository earlier:
remote: remove the file manually to continue.

Joe Dahl-Fisher February 4, 2022

I tried GC too, but it didn't help

I wonder if the best option is just to delete the remote develop branch and push the local again? Given that its currently me using this repo...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events