1

I have the following situation: master is 2 behind on origin master

How I got in this situation: By firstly applying 'Reset master to this commit' in Sourcetree. But then I realised I should have reversed the pushed commits How to rollback everything to previous commit. That's what I did afterwards. As I am pretty new to Git, to test out, I pulled the 2 unwanted commits, realised again I didn't want them, and then redid the above again except for the pulling. I tried to reverse the two unwanted commits again but I was only able to reverse one and got the following message:

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

I tried to reset the origin/master to my local master pointer. Following Git, How to reset origin/master to a commit?, this needs to be done

git checkout master git reset --hard e3f1e37 git push --force origin master

When I do git checkout master I get the same message again. Even if I want to pull or stage file for the next commits I get the same message.

So imo there's no other git process running. It's definitely possible that a git process is crashed with all my try outs and the (Unity) application running on the repository. But which file to remove manually? How to find it?

I solely use this repository. So I wouldn't mind a drastic solution as long as I have a clean copy to work on again. Because now with every git action I do, I get the above message.

EDIT: The solution is the same as mentioned in the possible duplicate link. The situation that produced the error not. I,for example, and only ET knows why, didn't look up the error message. Maybe there will be others that come across this particular situation. So is it a duplicate or not? Please tell me.

Nikola
  • 13
  • 6

1 Answers1

0

But which file to remove manually?

The error message tells you: /Users//.git/index.lock.

How to find it?

Presumably you have deleted your username from the error message, but if you navigate to C:\Users\[username]\.git (Windows) or /Users/[username]/.git (macOS) you will see index.lock which you can delete.

So I wouldn't mind a drastic solution as long as I have a clean copy to work on again.

You can clone the repository again.

ta.speot.is
  • 26,914
  • 8
  • 68
  • 96
  • 1
    Thx, that did it! So I could make that pending commit. 2behind and 1ahead now. Is now the moment to do the hard reset and the force push to the origin? I wanted to upvote (and not only for the funny xkcd cartoon:)), but I have to start a reputation first. – Nikola Jan 11 '18 at 10:50
  • 1
    Ok. That certainly worked. I reset the origin master to make last commit via the hard reset and force push. Back to my correct working copy. Thanks again. Learned a few things on the way about pushing and pulling and will start working on feature branches! – Nikola Jan 11 '18 at 11:27