Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore won't ignore the directory

Tags:

git

xcode4

I'm trying to ignore the xcuserdata folders that xcode 4 modifies and they keep come back despite being in my .gitignore file.

My .gitignore file as one line:

xcuserdata

Yet as soon as I change anything UI in xcode, I get this:

#   modified:   XXXXXXXX.xcodeproj/project.xcworkspace/xcuserdata/XXXX.xcuserdatad/UserInterfaceState.xcuserstate

I have done a...

git rm -r --cached XXXXXXXX.xcodeproj/project.xcworkspace/xcuserdata/XXXX.xcuserdatad/UserInterfaceState.xcuserstate

...and tried...

git rm -r --cached XXXXXXXX.xcodeproj/project.xcworkspace/xcuserdata

...followed by a commit. I have done this close to 10 times and it just won't go away and be ignored. It keeps coming back.

What am I doing wrong? There is clearly something I am not understanding. The file did get added to the repository when I first created it and now I'm trying to get rid of it.

I just want that file to become completely untracked like it had never been added to the repository.

like image 945
Roger Gilbrat Avatar asked Sep 26 '11 00:09

Roger Gilbrat


2 Answers

After doing

git rm -r --cached XXXXXXXX.xcodeproj/project.xcworkspace/xcuserdata

check that git status tells you that the files under that folder have been deleted. Then after your commit, ensure that git says there is nothing to commit.

The fact that you have done this "10 times" and it comes as modified shows that you are not doing it right and the folder ( actually the files within it) are still tracked.

Apart from that the content of the .gitignore seems fine and I have even confirmed on my repo that it works.

like image 163
manojlds Avatar answered Nov 11 '22 00:11

manojlds


If you can't push your commit just because UserInterfaceState.xcuserstate has been modified, here's a quick fix:

  1. Open the Organizer, go to Repositories, copy your the commit's code (something like f01a2147218d by username)
  2. Open the terminal, go to your project's folder, do git reset --hard f01a2147218d
  3. Push the commit!
like image 42
Eric Avatar answered Nov 11 '22 01:11

Eric