我使用Git进行Xcode 4项目版本控制。我明确地添加了ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState。xcuserstate到.gitignore,但是Git不会忽略它。有人知道为什么吗?


当前回答

如果你使用GitHub,这里有一些演示和快捷方式,基本思想是一样的。

1. 像这样打开终端

2. 将下面的命令粘贴到终端,后面加一个空格,然后像这样粘贴.xcuserstate文件的路径

Git rm——缓存

3.确保你有正确的git忽略,然后提交代码:)

其他回答

你也可以忽略Xcode首选项本身的文件。

从https://www.toptal.com/developers/gitignore生成gitignore文件

去Xcode ->首选项->源控制-> Git ->添加列表中所有忽略项…尽管UI并不是真的有用&你必须单独添加所有项目,但在这里添加忽略文件肯定有效。

如果你使用GitHub,这里有一些演示和快捷方式,基本思想是一样的。

1. 像这样打开终端

2. 将下面的命令粘贴到终端,后面加一个空格,然后像这样粘贴.xcuserstate文件的路径

Git rm——缓存

3.确保你有正确的git忽略,然后提交代码:)

如果被忽略的文件一直出现在未跟踪列表中,你可以使用git clean -f -d 把事情弄清楚。

1.

git rm --cached {YourProjectFolderName}.xcodeproj/project.xcworkspace/xcuserdata/{yourUserName}.xcuserdatad/UserInterfaceState.xcuserstate

2.

git commit -m "Removed file that shouldn't be tracked"

3. 警告:首先尝试git clean -f -d——dry-run,否则你可能会丢失未提交的更改。

然后: Git清除-f -d

这里有一个关于如何递归地从git历史中删除有问题的文件的很好的解释:http://help.github.com/remove-sensitive-data/

非常有用,否则工具在试图显示那些不应该首先检查的巨大文件上的差异时往往会“挂起”……

以下是你可以做的(简而言之)来摆脱最大的东西:

cd YourProject
git filter-branch --index-filter 'git rm --cached --ignore-unmatch -r YourProject.xcodeproj/project.xcworkspace' HEAD
# see what you want to do with your remote here...
# you can: git push origin master --force
# or you can delete it and push a fresh new one from your cleaned-up local...
rm -rf .git/refs/original
git gc --prune=now
git gc --aggressive --prune=now

对我来说非常有用:)

这对我很有用

打开包含项目文件project的文件夹。Xcworkspace。 这样写:git rm——cached *xcuserstate

这将删除文件。