iOS项目,添加忽略文件后发现UserInterfaceState.xcuserstate还是没忽略。
.xcuserstate是什么
看起来像是什么记录状态的文件。
xcuserstate files are generated from within Xcode and saved in your project bundle to remember your last opened file, the open state of any group folders, open tabs, and any other user setting your project might need to remember. For purposes of revision control, you should ignore them or leave them out if at all possible.
上面是stackoverflow说的,这个文件打不开,也不清楚用什么去查看里面到底是什么内容。
如何忽略.xcuserstate
需要做如下几步处理:
- 添加忽略内容到.gitignore
cd Project/.../... # 进入到本地git仓库
ls -la # 查看所有文件
open .gitignore # 打开gitignore文件
在里面添加下面的忽略内容
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
添加并保存。
- 删除仓库暂存区.xcuserstate的缓存并提交
git rm --cached Project/xxx.xcworkspace/xcuserdata/xxx.xcuserdatad/UserInterfaceState.xcuserstate
➜ xxx git:(master) ✗ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: .gitignore
deleted: Project/MMVoiceEngine.xcworkspace/xcuserdata/encompass.xcuserdatad/UserInterfaceState.xcuserstate
git add .
git commit -m "添加UserInterfaceState.xcuserstate忽略"
git pull
git push