忽略 Git 中 UserInterfaceState.xcuserstate 问题

自己平时开发自己的东西都用的 SoureTree 来管理项目的,每次打开项目,明明什么都没修改,都会莫名其妙多了条修改记录,如图:

《忽略 Git 中 UserInterfaceState.xcuserstate 问题》

一番查找之后发现:我的项目在 GitHub 上创建的时候,没有添加 .gitignore 文件,也就是:

《忽略 Git 中 UserInterfaceState.xcuserstate 问题》

那么如果要避免这个问题,我们可以在创建项目的时候,让 GitHub 帮我们加上 .gitignore 文件。除了这样,我们还可以手动添加,先去 gitignore 上找到对应的版本,拷贝下来。(我这里拿的 Objective-C 版本的)

先:

1.cd 到有 .xcodeproj 或者 .xcworkspace 文件的目录下
2.touch .gitignore
3.open .gitignore
把刚才拷贝的内容放进去,保存退出。

接着:

git add .gitignore
git commit -m "Add .gitignore file"
git push

最后,如果你的项目是支持 .workspace

git rm --cached [项目名].xcworkspace/xcuserdata/[用户名(就是你电脑的用户名字)].xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
git push

如果你的项目只有 .xcodeproj

git rm --cached [项目名].xcodeproj/project.xcworkspace/xcuserdata/[用户名].xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
git push
    原文作者:ifelseboyxx
    原文地址: https://segmentfault.com/a/1190000012573067
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞