如果你看不到.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到終端 ?然后就可以執(zhí)行命令了
4.在同 .git目錄下創(chuàng)建.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