I'm getting this message when trying to rebase interactively using source tree.
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.
fatal: Unable to create 'X:/sources/project/.git/index.lock': File
exists.
The problem is that X:/sources/project/.git/index.lock doesn't exist
All the other solutions on SO didn't work for me since they all say to remove this file.
I'm on a Mac and ran into basically the same issue.
When running git rebase -i master, I received an error:
fatal: Unable to create 'path/to/file/.git/index.lock': File exists.
The index.lock file didn't exist in my .git/ directory. But there was an index file (no filetype extension). So I aborted the rebase.
After a ton of searching, I finally decided to just create the file:
touch .git/index.lock
I tried rebasing again, but that didn't fix the issue (this time the file really did exist). So I removed it:
rm .git/index.lock
That did the trick. The rebase had conflicts this time (which was odd since I aborted the rebase previously), but I just addressed each conflict and then let the rebase continue:
git rebase --continue
I hope this helps someone else who ends up in a similar situation.
Use rm -rf X:/sources/project/.git/index.lock to remove the lock and save yourself a headache. Also, the index.lock exists, however, the .git folder is hidden. So, use ls -la X:/sources/project/.git to see the content of a hidden folder.
I had the same issue using Github Desktop. I watched the .git directory and the index.LOCK file would appear and disappear. It never persisted for long, so was not there to delete. I investigated a little as other solutions online did not work for me and found that comparing permissions to folders that I was able to commit they had one difference: the .git folder that gave me the error had full control like the others, but it was inherited from its parent. I went to properties->security->advanced and removed then re-added the permissions without inheriting them from the parent. After that I was able to commit my changes without an error.
OK, this is really strange, but for me, the following worked:
Create the file .git/index.lock from Windows explorer
Delete the file again (from git bash, I don't know if this is important)
Then, the command I was executing (git rebase --continue, in my case) succeeded. I have no idea why this procedure worked, though. This should not make any difference...
I disabled indexing of the .git folder and it helped to me to get rid of the message
#Manza: I came across the same issue. There is no index.lock file existing and still it throws an error related to file existence.
I created a patch of my changes and did a clone again. Now when I do a commit, it works all fine. I know this is not the right direction. But this is the go to when the index.lock doesn't get created and still we get this error.
for ios mac remove rm -rf from this location .git/modules/ios or can manual delete
Step —
1)-Open terminal .
2)-Open project file location.
3)-Rum command - defaults write com.apple.finder AppleShowAllFiles YES.
Now u can see hidden file in Mac OS.
4)-Rum command - cd .git/modules/ios (In my case I am running React code).
5)-Now either open folder and delete index.lock or use “rm” command .
6)-Thats its - now try to commit and push .
Related
I have a folder which contains .patch files only. When I run a command
for myPatch in /d/FolderWithPatches/*.patch; do git am "$myPatch"; done
I receive a fatal: previous rebase directory .git/rebase-apply still exists but mbox given. error. I tried both using git am --abort and simply deleting the rebase-apply folder - neither of this helped actually. Can you help me to fix my issue?
EDIT: I know the issue on Git error: previous rebase directory .git/rebase-apply still exists but mbox given. The answers provided there don't help me to deal with the problem.
I have checked almost all the questions on SO but nothing has worked for me. The issue that I'm unable commit the Contents.json file of .xcassets whatsoever. Whenever I add new images to .xcassets the source control does list the images but not the Contents.json file. I'm using a bitbucket repository and not even SourceTree is showing this file in the uncommitted changes. Even tried adding all the files via terminal.
git add --all
Any guess why this is happening and what could possibly be the solution?
Update: The .gitignore file looks like:
ProjectName.xcworkspace/xcuserdata
ProjectName.xcodeproj/xcuserdata
*.xcscheme
xcschememanagement.plist
And .git/info/exclude looks something like:
.DS_Store
UserInterfaceState.xcuserstate
A lot of time has passed, but it seems I know what it is. I encountered the same problem, and every time I added resources, I had to manually do the following steps: git add -f
However, I found out about the command: git status --ignored
The command shows all ignored files. After that, I made the git add -f command manually, and it worked.
Probably you have .xcassets/Contents.json in one or more of the three ignore files .gitignore, .git/info/excludes and ~/.gitexclude.
If that is not the case then try executing below command which will ask Git to start tracking the file again:
git update-index --no-assume-unchanged <file>
For your case:
git update-index --no-assume-unchanged .xcassets/Contents.json
I've created a project to practice using Git with Xcode and GitHub. After a lot of work, I've got the repositories created both locally and remotely. I just tried to make a commit and got this error:
Here's what I'm trying to commit:
The last things I did before I got this error were:
I added a .gitignore file using the GitHub Swift template in order to remove the .xcscheme file from the cache
from the Terminal, I ran 'git rm --cache'
I created the test_file and then tried to Commit
But I can see the folder in the finder:
I looked around SO a lot and found many questions about git commit problem but what I found had mostly to do with diacritics and other issues that aren't the same as mine.
Did the 'git rm --cache' lead to this situation? What can/should I do to safely correct this problem?
Thanks
Update: Seems I really got myself into pickle. I've got nested 'git-practice-project' directories several levels deep:
I've started at the deepest directory, did an ls, and a git status, the backed myself up to the top doing the same thing at each level. It looks like only the two highest directories have uncommitted changes and the project.pbxproj file exists in both of them.
I don't use Xcode's SCM features so I am not sure why Xcode is confused here. But it looks like the files under git-practice-project/git-practice-project aren't known to git yet. You need to add the directory to git. On the command line from the project's root directory you could try:
git status
That should list your files that have been modified, deleted, and that aren't part of the git repo yet.
Add the directory and its contents:
git add git-practice-project
Once you have done that, you should be good to go to use the SCM tools in Xcode again.
Update: In Xcode, you can select the file that is marked with the ? and then go to the Source Control menu and select Add Selected Files.
Ran into this with Xcode 10, with newly added files. You first need to add the new files to the repository. Simply select the file in the navigator on the left, right-click, then Source Control in the pop-up, and select "Add Selected Files". After this the commit will work.
I just used a "git clean" command and managed to delete my Documents, Music, and other directories. Is there a way to undo this and somehow get those files back? I did this via Terminal on Mac. Time Machine isn't setup either.
I'm afraid those files are gone. git clean is not reversible since those files were not tracked by git.
From the comments it looks like you had your home folder as git repo, but with nothing tracked.
Running git clean -f removed any file inside the home folder (included the one in the subdirectories), leaving only empty subdirectories (the -d option is required for removing them too).
I'm sorry to inform you that you definitely wiped out your whole home directory. Next time you run a git clean use the -n options to perform a dry run and check what's going to happen before it's too late.
Unfortunately git clean removes all the untracked files, meaning the files that are deleted are not able to be recovered using git. You might be able to check your trash to see if the files still exist there.
I have just recently backed-up my XCode C++ project on my pendrive, using
rsync -avu
Since then, the version control for my project is grayed-out on every files, I can modify the files and not see the "M" nor the "A" sign. The only files still having version-control working "shared" files for which it works correctly. (Those shared files belong to a different project called "Shared").
I have tried git commit -m, git add . and even git init where the files were. Nothing worked.
Can you please help restoring version control for my project?
UPDATE:
Answers for the questions in commens (and answers):
my git repository is on my local hard drive.
I went to the Organiser-repository pane in XCode and I see my recent git commit -m "sth" as "sth" az a commit. I have a single branch: master.
Im not sure what command would be good to test git, as my commits work (theoretically).
I have a folder named .git in the project folder.
git log is working, showing the same as XCode Organiser-repository pane.
I think the XCode just can't synchronise with the git for some reason, and I don't know how to correct that.
First off, this is not an answer that will fix your problem, I just try to provide some help that might get you closer to a diagnosis.
Git stores its files in a folder named .git. Check if this folder is present in your project. If it's not then your Git repository is gone.
Next, try some basic command such as git log. For this to work, you must first cd to your project folder (or a subfolder thereof), because whenever you run a Git command it will look for the .git folder in the cwd or a parent folder. If git log does not work then your Git repository is broken in some way. Someone else will have to step in to further diagnose the problem, as I am no expert on this subject.
Finally, you should also check whether your rsync command has really sync'ed your project's .git folder with the backup's .git folder. Use this command:
diff -rq /path/to/project/.git /path/to/backup/.git
If there is no difference (as I would expect if rsync has worked correctly) then the problem with your Git repository is both in your project and in your backup. If there are differences then it might be worthwile to try your next steps on a copy of the backup (it should be fine to make the copy in the Finder).
Good luck.