忽略 Git 中 UserInterfaceState.xcuserstate 问题

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

一番查找以后发现:个人项目在 GitHub 上建立的时候,没有添加 .gitignore 文件,也就是:github

2.

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

先:spa

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

接着:3d

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

最后,若是你的项目是支持 .workspacecode

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

若是你的项目只有 .xcodeprojblog

git rm --cached [项目名].xcodeproj/project.xcworkspace/xcuserdata/[用户名].xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
git push
相关文章
相关标签/搜索