Git 中无法忽略 .xcuserstate 的解决方法

在平时的 iOS 开发中使用 Git 时会遇到这样的问题,明明在 .gitignore 文件中添加了 .xcuserstate 忽略,之后每次 push 时文件改动中还是会出现 UserInterfaceState.xcuserstate 文件,下面是解决方法。
 
1.打开终端,cd 到你的项目文件夹下,然后输入以下命令
git status

2.然后会显示 UserInterfaceState.xcuserstate 文件有改动,这时候复制 modified: 后面的地址

3.接着输入 git rm --cached 刚才复制的地址 ,如下:

git rm --cached client_swift_fm_a/client_swift_fm_a.xcworkspace/xcuserdata/Jonzzs.xcuserdatad/UserInterfaceState.xcuserstate

4.接着将代码提交推送到服务器

git commit -m "删除xcuserstate文件"
git push
 
原文地址:https://www.cnblogs.com/zhangliukou/p/12619652.html