美文网首页iOS知识总结iOS 的那些事儿
git中忽略UserInterfaceState.xcusers

git中忽略UserInterfaceState.xcusers

作者: KSFZHS | 来源:发表于2017-06-19 10:34 被阅读136次

    1.UserInterfaceState.xcuserstate是什么?

    该文件为xcode默认自带文件,是xcode的配置信息,git会用这个文件记录下来。
    比如:手动删除此文件,退出xcode后重启xcode,此文件会自动创建并跟踪

      结论:此文件无需push,应忽略
    

    2.使用.gitignore忽略无效,如何解决?

    终端输入以下指令:

      git rm --cached 此处填写你的工程名称.xcodeproj/project.xcworkspace/xcuserdata/此处填写你的用户名称.xcuserdatad/UserInterfaceState.xcuserstate
      git commit -m "Removed file that shouldn't be tracked"    
      git push
    

    注意:
    执行以上三条指令有以下两个前提

    • 得先在工程目录(和.git仓库同路径的目录下)配置有 .gitignore 文件,它才能生效!
      1.先创建touch .gitignore,
      2.打开open .gitignore,

      *.xcuserstate  
      project.xcworkspace  
      xcuserdata  
      UserInterfaceState.xcuserstate  
      project.xcworkspace/  
      xcuserdata/  
      UserInterface.xcuserstate  
      
      3.将上面内容粘贴进去,
      4.保存关闭,
      5.添加到缓存区,git add .gitignore
      6.提交git commit -m "添加了.gitignore文件"
      7.推送git push    
      

    配置完.gitignore文件后,注意下面一个前提

    • 要进入该工程的路径中,也就是.xcodeproj的上一级,否则会出现以下错误
      fatal: path spec 'ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate' did not match any files

    满足以上两个前提后,执行以上三条指令即可

    参考资料及链接:

    This helped me: 1) quit xcode; 2) go to the project directory and do an "ls -la" from the terminal app to make sure you see the .git and .gitignore files; 3) change "ProjectFolder" in the example above to the name of your project; 4) do the two git commands that matt shows; 5) Relaunch XCode and do a commit and verify that the xcuserstate file is no longer listed.
    https://stackoverflow.com/questions/6564257/cant-ignore-userinterfacestate-xcuserstate
    http://www.jianshu.com/p/6f464f555f2d

    相关文章

      网友评论

      本文标题:git中忽略UserInterfaceState.xcusers

      本文链接:https://www.haomeiwen.com/subject/jukgqxtx.html