2

This isn't a duplicate. I have looked at this stack overflow post and this post and tried their solutions, which didn't work.

I'm using Ubuntu 16.04 and trying to push a project to Github.

When I run:

git push jr master

I get this error:

error: update_ref failed for ref 'refs/remotes/jr/master': cannot lock
ref 'refs/remotes/jr/master': Unable to create 
'/home/john/Desktop/john-rykken-V2/.git/refs/remotes/jr/master.lock': 
File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
Everything up-to-date

I have run the following commands:

rm -f .git/refs/heads/master.lock
rm -f .git/index.lock

Neither worked. I've also rebooted my machine and run ps -a | grep git, but didn't find any running processes. Finally, when I go into my project directory and manually search for master.lock, I can't find it.

Suggestions? My next step is re-cloning the repository.

John
  • 521
  • 1
  • 7
  • 23

1 Answers1

4

You've probably ran a git command with sudo, which has caused some of the files in your .git repository to be owned by root. Try running this command to change the ownership of all the files in your repository to your user:

sudo chown -R john /home/john/Desktop/john-rykken-V2/.git

I'm assuming here that you are trying to run git with user john. Otherwise, change that to the correct user.

Edit:

As it turns out, the file on the error message had to be deleted: rm -f .git/refs/remotes/jr/master.lock

Danilo Souza Morães
  • 1,481
  • 13
  • 18