开发者

.gitignore won't ignore the directory

开发者 https://www.devze.com 2023-04-07 04:32 出处:网络
I\'m trying to ignore the xcuserdata folders that xcode 4 modifies and they keep come back despite being in my .gitignore file.

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.xcode开发者_StackOverflow中文版proj/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.


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.


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!


try using xcuserdata/ in your .gitignore

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号