I am still getting this error message, when I try to move my project tree on to git repo.
I checked the permissions of my directory with this project and these are set on 777. In terminal in the directory with my_project
I set:
git init
and then if I try
git add .
or
git commit -m "first upload"
so I'll get the error
fatal: Unable to create '/path/my_proj/.git/index.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.
I tried also create a new repo and there to commit it, but unfortunately still the same error message.
What is the cause of problem?
Try
rm -f ./.git/index.lock
In your repository directory. The error message is rather explicit as to what causes it typically, so if you have no other git processes running (which is the normal case), go ahead and delete that file.
In Windows, do this in the command prompt from the repo directory:
cd .git
del index.lock
UPDATE: I have found that I don't need to do this procedure if I wait a moment after I close out the files I'm working on before I try to switch branches. I think sometimes this issue occurs due to git catching up with a slow file system. Other, more git-knowledgeable developers can chime in if they think this is correct.
rm -f index.lock
)
Try quitting Xcode - since it's a git client, you have to quit Xcode to avoid problems with git on the command line.
In my .git directory, there was no index.lock file. So, using the Git Bash shell, I ran...
cd .git
touch index.lock
rm index.lock
The touch command created the file, and the problem went away.
index.lock
did not exist; (3) I used the above touch
command; (4) my git client stopped functioning normally (at best, it slowed to a crawl); (5) I deleted index.lock
; (6) the repository began functioning normally again.
touch index.lock
implies John was on *NIX, but I just did the equivalent on Windows 10 (create an index.lock
file with a text editor, delete it immediately, and profit), and the problem's gone.
index.lock
file that you just created with touch
.
I was having the same problem. I tried
rm -f ./.git/index.lock
and the console gave me an error message. Then, I tried
rm --force ./.git/index.lock
and that worked.
Good Luck! This works super
Did you accidentally create the repository using the root user?
It just happens that I created the git repository as the root
user.
I deleted the git repository and created it again without sudo
and it works.
You need to delete the index.lock file.
In Linux
cd .git
rm -f index.lock
In Windows(10), do this in the command prompt from the repo directory:
cd .git
del index.lock
i have this problem too, and i find it really a permission problem. so i do this:
sudo chown -R : .git #change group
sudo chmod -R 775 .git #change permission
then ererything is great, and gaa is success.
and then i use gp, i get another error almost the same error
sudo chown -R "${USER:-$(id -un)}" . #use this can fix the problem
In Windows, I only managed to be able to delete the lock file after Ending Task for all Git Windows (32bit) processes in the Task Manager.
Solution (Win 10)
1. End Task for all Git Windows (32bit) processes in the Task Manager
2. Delete the .git/index.lock file
Run Task Manager, Locate Git for windows process and kill it. Delete index.lock file under .git folder It worked for me !
In Mac OS X do this in the command prompt from the repo directory:
cd .git
rm index.lock
The solution that worked for me was closing sublime text because the running git process was initiated by the editor.
If after you try:
rm -f ./.git/index.lock
you get:
rm: cannot unlink 'index.lock': Permission denied
Try closing all software that might be using Git. I had Source Tree and Visual Studio opened and after closing both the command worked.
I think there's a better solution than removing the file (and god knows what will happen next when removing/creating a file with sudo):
git gc
./.git/index.lock
no existing), this solved my issue :)
If you are using one of #intelliJ
IDEs and receiving this msg (i'm using #webtorm
), please notice that this problem can occur because of hiding one of project folders (inside settings), and this can prevent GIT
from merging.
In my case the solution was to wait 5 minutes. Obviously my previous operation was still running but I just didn't know it. I was using tortoise git on windows.
If it's a submodule, try this instead on your repository directory :
rm -f ../.git/modules/submodule-name/index.lock
change submodules-name to your submodule name.
Use This:
rm -Force ./.git/index.lock
DO NOT USE the Atom platformio-atom-ide-terminal
Plugin to do this. USE THE TERMINAL OF YOUR DISTRO DIRECTLY.
I kept getting this error while rebasing/squishing commits and didn't know why because I had done it before several times.
Didn't matter how many times I would delete the index.lock
file, every time it would fail.
Turns out it was because I was using the ATOM EDITOR terminal plugin. Once I used the terminal that ships with Ubuntu it worked like a charm.
You have problem with .git/index.lock
so delete it using below command.
Command:
sudo rm -rf .git/index.lock
I tried it with many methods several times but this one worked for me (I used PyCharm's terminal) :
$ cd .git/
$ rm -f index.lock
Then I tried again to create an empty git repo :
$ git init
$ git add .
$ git commit -m "commit msg"
The resolution for this problem is copying the three xcode/project files in the directory and then creating new directory (Whereever else) and then paste the three files/directories.
Also we can just kill git process. I receive the same issue via GUI app for git, something goes wrong and git makes some work infinitely. Killing process will freeze application that works with git, just restart it and everything will be ok.
In case, for whatever reason, you are doing a rebase from a folder that's being sync'd by a cloud service (dropbox, drive, onedrive, etc), you should pause or turn off syncing as it will interfere with permissions during the rebase.
For me it was
rm -r .git-credentials.lock
I had changed my directory permission so I knew it could be permission related. In my case I removed unwanted (_www) users and then applied read/write permission to everyone by apply changed to all contents. This is on Mac
https://i.stack.imgur.com/MU76k.png
All the remove commands didn't work for me what I did was to navigate there using the path provided in git and then deleting it manually.
A little adding because I had to use different answers to get the actual solution (for me).
This did it for me:
Open branch you are working on Open terminal (I use terminal in Git GUI) Typ in command: cd .git Typ in command: rm -f index.lock
Some may have to use -Force
instead of -f
. You can check the command lines of your terminal by executing a command in your terminal something like: git help
.
simply go to D:/project/androidgc/.git/ this directory and delete index.lock this worked for me.
In case someone is using git svn, I had the same problem but could not remove the file since it was not there!. After checking permissions, touching the file and deleting it, and I don't remember what else, this did the trick:
checkout the master branch.
git svn rebase (on master)
checkout the branch you were working on
git svn rebase
Success story sharing
git push
to push your changes to the web server. Details on how this works are here: gitready.com/beginner/2009/01/21/pushing-and-pulling.htmltouch .get/index.lock
returnstouch: .get/index.lock: No such file or directory
ls -l
to see permissions, then usesudo chown -R username ./*
andsudo chgrp -R username ./*
to change user and group to your own for all files in the project.