1> 退出 Xcdoe,打开终端(Terminal),进入到你的项目目录下。
2> 在终端键入 git rm --cached <YourProjectName>.xcodeproj/project.xcworkspace/xcuserdata/<YourUsername>.xcuserdatad/UserInterfaceState.xcuserstate
终端返回:rm 'QFormDataExample.xcodeproj/project.xcworkspace/xcuserdata/JHQ0228.xcuserdatad/UserInterfaceState.xcuserstate'
3> 提交更新,在终端键入 git commit -m "Removed file that shouldn't be tracked"
终端返回:<master 734ff0a> Removed file that shouldn't be tracked
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 QFormDataExample.xcodeproj/project.xcworkspace/xcuserdata/JHQ0228.xcuserdatad/UserInterfaceState.xcuserstate
4> 在 .gitignore 文件中加入如下几行,或者在 GitHub Desktop 中右击 UserInterfaceState.xcuserstate 更新,选择 Ignore all .xcuserstate files
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
5> 提交更新,重新打开 Xcode commit, push。
然后出现如下图所示的.gitignore文件
我们需要点击左侧的小方框勾选add进来
然后commit提交到本地仓库,最后push到远程仓库
然后重新打开Xcode