无法从 xcode 中的提交中排除用户界面状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17312775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't exclude user interface state from commit in xcode
提问by titicaca
I can't exclude user interface state file from commit.
我无法从提交中排除用户界面状态文件。
Every time I'm trying to push to github it asks me to commit first and insert user interface state file into the changes (even if I didn't move the mouse or interface at all it still is shown to commit!).
每次我尝试推送到 github 时,它都会要求我先提交并将用户界面状态文件插入到更改中(即使我根本没有移动鼠标或界面,它仍然显示为提交!)。
I tried different methods, described in other similar topics. For example, I tried to add all possible cases of user interface into the .gitignore in root, like this:
我尝试了其他类似主题中描述的不同方法。例如,我尝试将所有可能的用户界面情况添加到 root 中的 .gitignore 中,如下所示:
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
It didn't work. I tried to clean the cache and reset git, didn't help.
它没有用。我试图清理缓存并重置 git,没有帮助。
Git status command says the following: "modified: .xcodeproj/project.xcworkspace/xcuserdata/.xcuserdatad/UserInterfaceState.xcuserstate"
Git status 命令表示如下:“修改:.xcodeproj/project.xcworkspace/xcuserdata/.xcuserdatad/UserInterfaceState.xcuserstate”
And it looks like this
它看起来像这样
Please help (it is driving me crazy)!
请帮忙(这让我发疯)!
回答by VonC
If those files are already committed, you need to remove them from the index before seeing your .gitignore file work.
如果这些文件已经提交,你需要在看到你的 .gitignore 文件工作之前从索引中删除它们。
git rm --cached *.xcuserstate
# or
git rm -r --cached project.xcworkspace
回答by Stuart P.
To add on to VonC's answer after calling -rm you also have to commit and then push (do this in the terminal BEFORE touching Xcode or it's git tools again), that solved my problem.
要在调用 -rm 后添加 VonC 的答案,您还必须提交然后推送(在触摸 Xcode 或再次使用 git 工具之前在终端中执行此操作),这解决了我的问题。
So
所以
git rm --cached *.xcuserstate
git commit -m "Removed cached files"
git push
Then you can touch Xcode again
然后你可以再次触摸Xcode