如果你看不到.git目录,你需要让隐藏的文件可见。具体做法就是打开一个Terminal窗口,输入以下命令:
1.defaults write com.apple.finder AppleShowAllFiles TRU
2.重启Finder
3.打开终端 切换到你的项目目录下 删除本地的UserInterfaceState.xcuserstate缓存
![](https://img.haomeiwen.com/i1499375/4c17740208e97d11.png)
(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)
![](https://img.haomeiwen.com/i1499375/4c009b5619b538c5.png)
(2)
![](https://img.haomeiwen.com/i1499375/d6acbf0dfbecc53a.png)
(3)
![](https://img.haomeiwen.com/i1499375/b23df0678926d9e1.png)
(4)
![](https://img.haomeiwen.com/i1499375/9dc3d92e9a410ef6.png)
(5)
![](https://img.haomeiwen.com/i1499375/c82da7d30f811c40.png)
直接 在终端cd 拖拽Sunny.xcuserdatad到终端 然后就可以执行命令了
4.在同 .git目录下创建.gitignore文件。
![](https://img.haomeiwen.com/i1499375/aa5406fcebc28649.png)
(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
网友评论