美文网首页
iOS 无法忽略UserInterface.xcuserstat

iOS 无法忽略UserInterface.xcuserstat

作者: Cingjin | 来源:发表于2021-09-17 11:53 被阅读0次

问题描述:

Q1、项目提交的时候,除了修改文件以为,很烦人的会出现如下图的文件,有时候项目稍作修改或者操作,就会出现这个文件(至于这个文件是什么做什么的不做讨论)

-w1029

Q2、我们用的git可视化工具sourcetree,但是在sourcetree的忽略设置中已经设置了忽略.xcuserstate,可是不生效(不明其究竟)

-w640

解决思路和方案:

方案一

尝试过修改sourcetree忽略文件中添加UserInterface.xcuserstate,结果提交还是忽略不了。UserInterface.xcuserstate文件


-w651

方案二

遇到问题先Google,毕竟自己是面向Google编程,有的小伙伴遇到这个问题,他们解决方式是

//cd 到项目目录下
git status
//会出现一个 modified(修改): xxxx/UserInterfaceState.xcuserstate 的地址
git rm --cached  xxxx/UserInterfaceState.xcuserstate
git add .
git commit -m '删除xcuserstate'
git pull 
git push

结果:有的同学通过这个方法是解决了这个问题,但是对我还是无效。

方案三

提交的时候出现这个文件,那就是git忽略文件的问题,检查项目中是否存在.gitignore文件,发现项目目录下是没有这个文件的,那就创建.gitignore文件,把需要忽略的文件后缀添加进去,然后提交。

// *.xcuserstate
// UserInterfaceState.xcuserstate

// cd 到项目目录下
ls -la //查看项目所有文件(包括隐藏文件)
// 如果没有.gitignore文件,执行以下命令,然后在编辑.gitignore文件,把要忽略的文件类型添加进去
// 如果存在则看文件中是否包含要忽略的UserInterface.xcuserstate文件类型,没有则添加进去,保存
vim .gitignore

git status
//如果会出现一个 modified(修改): xxxx/UserInterfaceState.xcuserstate 的地址,如果没有跳过这一步
// 如果有必须执行这一步,删除git 仓库中xxxx/UserInterfaceState.xcuserstate缓存文件
// 否则提交还是会有.xcuserstate文件
git rm --cached  xxxx/UserInterfaceState.xcuserstate

git add . 
git commit -m '忽略UserInterface.xcuserstate文件类型提交'
git pull 
git push
-w676 -w231

结果:在后面的修改提交中没有烦人的.xcuserstate了

注:以上个人遇到的问题解决思路和方案个人观点,只是解决了我的问题,有更好方案的小伙伴欢迎指正👏🏻

相关文章

网友评论

      本文标题:iOS 无法忽略UserInterface.xcuserstat

      本文链接:https://www.haomeiwen.com/subject/zsbjgltx.html