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