I got this strange error when delete files in xcode - iphone

When I try to delete things from my xCode project I get this strange error does not know why. It's seems like git error but I have not created git repository in my project.
This is the error:
fatal: Unable to create '/Users/dilipmanek/.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.
Plz help me solve this problem..

Exit XCode, go to a command prompt and type rm /Users/dilipmanek/.git/index.lock. Apparently you have a git repo of your entire home directory whether you meant to or not :)
If the git repository is there by mistake, you can go to a command prompt and type;
(always be careful with rm -r, it will remove all files under the directory given, so don't do it to your entire home directory for example)
rm -r /Users/dilipmanek/.git
...and remove the entire git repository. It will not affect any files that aren't placed in that directory, but make sure you've not copied anything you need to keep there.
The reason XCode won't delete the file is that when it finds a git repo, it will attempt to use it. Git locks files by creating a temporary file in the git directory, and if XCode crashes while doing any file operation, the file is left there and the next instance of XCode will think the repository is locked.

Related

Git ignore not ignoring directories

I'm trying to ignore obj, bin, debug type files/directories from my Visual studio project. I've followed the advice here:
ignoring any 'bin' directory on a git project
This is not working.
I've pasted the entire git ignore here:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
This is not working.
I've tried all sorts of things...
bin/
obj/
*bin/
*obj/
/bin/
/obj/
packages
MyProject/MyProject/obj/
MyProject/MyProject/bin/Debug/
MyProject/MyProject/obj/*
MyProject/MyProject/bin/Debug/*
The directories and their files are still being included when I run a git add. The .gitignore file is added and commited. What am I doing wrong???
EDIT: The files I'm trying to ignore aren't already being tracked. When I run a "git status" there are no pending changes. "nothing to commit, working tree clean". Then I run my VS program which modifies the files in those folders. Then I run another git status and all of the files show up as "modified"...
EDIT2: Does it matter if the files already exist? They are not being tracked but DO exist in the folder structure. When when I run the program they show up again as "modified". Then I have to run a "git checkout ." to remove them all. Then the cycle repeats...
If your file was already been tracked and committed before adding in .gitignore, it won't ignore it. You would require to remove it from index to stop tracking
For file
git rm --cached <file need to remove>
For Folders
git rm -r --cached <folder>
So that would be an issue in your case since Jenkins is still able to see the file in the repo
Hi look at the edit part ,
If you already have any folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won't stop tracking paths that are already being tracked just because they now match a new .gitignore pattern. Execute a folder remove (rm) from index only (--cached) recursivelly (-r).
git rm -r --cached yourfolder
Based on your "Edit 2" above, it sounds like you don't think these have been previously committed, but in reality, they have been. If it shows up as "modified", the git is recognizing the file has changed from the last version it has checked in. If the file was not already committed previously then it would show up as Untracked.
When you are running git checkout on those files, you are telling git to revert those files back to the last version that was checked into git.

github wouldn't remove a high volume directory

I have cloned a repository that has 3.8G of data. (Well, bordering stupidity but I mistakenly uploaded an image dataset.) Now, I would like to remove it but git rm -r wouldn't remove it. I need this directory to be removed from local as well as remote master repository. The command has been running for well over 2 days now. I believe it is stuck. Please I'd really appreciate if someone could tell me a way out of this situation. Thanks.
Problem 1: Deleting it from your local repository
You want to delete the images from your local repository.
Solution:
On the command line, do a rm -rf x, where x is the directory that contains the images, -r is the recursive flag used to delete directories and subdirectories contained within, and -f is the force flag to delete protected files.
Problem 2: Preventing it from being committed
You don't want the images to be pushed to the codebase/online repository.
Solution:
If you already deleted the files from your local repository, you can check that the directory was removed by running a git status command. The deleted directory should be printed in red font. All you need to do is git rm x to confirm that the directory is to be deleted and be removed from the codebase/online repository. Then, of course, run a git commit and then a git push <origin> <master>.
Alternative:
Although you said you wanted to delete the image set, next time if you want to keep it locally but prevent it from being pushed to the codebase/online repository, create a .gitignore file and specify the directory or file type you don't want pushed. A tutorial on .gitignore files can be found here.

How to end 'another git process' running in same repository?

After my first attempt at committing a couple of large folders (angular and django), git responded with:
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.
Previous posts recommend:
removing the index.lock in the .git folder.
I've done this, but the second that i resubmit "git add . " as part of my git push origin master routine, the index.lock file reappears in .git
Is there another solution? And what has happened to warrant this?
I've tried all the suggestions in the commented link
I'm working with this:
git version 2.13.5 (Apple Git-94)
In my case, index.lock wouldn't delete. Instead, I found that one of my django folders lacked a .gitignore, so I created one and included the following files:
include
lib
include
bin
.vscode
You might want to include more or less, depending.. Apparently, I was attempting to push a file that disagreed with git.

Hiding files that have been git rm --cached from the list of changed files in GitHub for Windows

In GitHub for Windows, files that have been git rm --cached still appear in the list of changed files. Is there any way to hide them?
You still need to add the files to your .gitignore file.
http://www.gitguys.com/how-to-remove-a-file-from-git-source-control-but-not-delete-it/:
The git rm command will allows you to remote a file from git control.
The –cached option to git remove allows you to leave it on your hard
drive.
Every once in awhile a file gets checked into git that isn’t supposed
to be there. Common examples are configuration files, project files
generated by your IDE with personal settings and even the occasional
object file that someone decided to check in. These files are needed,
so often you can’t delete them entirely and the process of copying
them somewhere else, removing them from git and then replacing is
painful, not to mention prone to error.
By adding the –cached option to the git rm command, you are able to
remote the file file from git control while keeping the file in your
working tree. They command syntax is:
git rm --cached file
Git will no longer track this file even though it is still on your
hard drive.
After running the above command, be sure to add an entry to your .gitignore file so that ‘file’ doesn’t show up in ‘git status’ and that it can’t accidentally be re-added later.

How can I move files & folders using git in Xcode 4?

I'm familiar with the differences between groups and actual directories in Xcode. I always create an actual folder in finder and drag it into the project, ensuring 'copy' is un-checked.
When I move folders, I delete the items by reference only, move them in finder, then re-add them.
Now I'm using git for the first time, and discovered in my testing that if I remove a directory using the method described above, I can't do a commit. Xcode tells me it can't switch to the directory because 'no such file or directory.' From what I've found online, git isn't notified of the directory changes when done in Xcode.
How can I move files & folders using git in Xcode 4 and have the compiler and git be aware of the moves so I can commit?
You shall not move files in a GIT repository using the Finder. You'd better use the move command from shell.
You then have to manually redresh links in XCode (or remove/add files again).
Moving a file is similar to the unix 'mv' command, with the 'git prefix:
git mv path destination
(use -f to override destination... with caution)
After you have made all your changes in the Finder, open a terminal window and navigate to your project's directory:
cd path/to/project
then run this command:
git add --all
This command will stage all of the changes and Xcode should be able to resume its management of the repository from here.