xcode git 忽略user interface state文件

如果你看不到.git目录,你需要让隐藏的文件可见。具体做法就是打开一个Terminal窗口,输入以下命令:

1.defaults write com.apple.finder AppleShowAllFiles TRU

2.重启Finder

3.打开终端 切换到你的项目目录下 删除本地的UserInterfaceState.xcuserstate缓存

(1)sksdeMacBook-Pro:Sunny.xcuserdatad Sunny$ls

UserInterfaceState.xcuserstate

(2)sksdeMacBook-Pro:Sunny.xcuserdatad Sunny$git rm --cached UserInterfaceState.xcuserstate

rm 'uhou.xcodeproj/project.xcworkspace/xcuserdata/Sunny.xcuserdatad/UserInterfaceState.xcuserstate'

(3)sksdeMacBook-Pro:Sunny.xcuserdatad Sunny$git commit -m "Removed the stupid strange file that shouldn't be tracked"

[master d7762db] Removed the stupid strange file that shouldn't be tracked

1 file changed, 0 insertions(+), 0 deletions(-)

delete mode 100644 uhou.xcodeproj/project.xcworkspace/xcuserdata/Sunny.xcuserdatad/UserInterfaceState.xcuserstate

如果找不到可以手动打开到文件夹

(1)

(2)

(3)

(4)

(5)

直接 在终端cd  拖拽Sunny.xcuserdatad到终端  然后就可以执行命令了

4.在同 .git目录下创建.gitignore文件。

(1)切换到工程主目录cd /Users/sks/Desktop/new_code/uhou1.0

(2)vim .gitignore 文件中加入如下几行

*.xcbkptlist

*.xcuserstate

project.xcworkspace

xcuserdata

UserInterfaceState.xcuserstate

project.xcworkspace/

xcuserdata/

UserInterface.xcuserstate

5. 重新打开Xcode commit, push。

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

推荐阅读更多精彩内容