【iOS开发】配置忽略文件.gitignore 文件

xiaoxiao2021-02-28  82

如果你的新项目使用git管理版本的时候没有配置忽略文件 .gitignore 文件,就会导致每次提交的时候都会出现UserInterfaceState.xcuserstate(视图修改缓存文件),Breakpoints_v2.xcbkptlist(断点调试缓存文件)这两个文件被修改。

一、那么出现这种比较烦人的东西,下面提供解决方法。

1、在终端上进入项目,与 .git 文件并列的地方,执行 vim .gitignore 操作

vim .gitignore

2、点击 i, 进入编辑状态,然后把你要忽略的文件名字输入,如果有多个,记得换行。

项目名.xcodeproj/project.xcworkspace/xcuserdata/电脑用户名.xcuserdatad/UserInterfaceState.xcuserstate 项目名.xcodeproj/xcuserdata/电脑用户名.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

3、点击 Esc, 输入:wq,退出编辑状态并保存。

4、再次使用命令 git status查看,你忽略的文件已经不存在了。

5、接下来执行提交,上传命令

git add . git commit -m ‘update .gitignore’ git push origin master


二、注意

如果上面的操作没能成功忽略掉 .gitignore中的文件,原因是 .gitignore 只能忽略那些原来没有被 track 的文件,如果某些文件已经被纳入了版本管理中,则修改 .gitignore 是无效的。

那么只能继续下面的操作:

先把本地缓存删除(改变成未track状态),一般删除项目中全部缓存,然后再提交。命令行操作如下:

git rm -r –cached . git add . git commit -m ‘update .gitignore’

这样子成功解决。

三、备注

更多忽略文件:

# Xcode # build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata *.xccheckout *.moved-aside DerivedData *.hmap *.ipa *.xcuserstate # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control # # Pods/

参考链接:http://www.cnblogs.com/zuopeng/p/4305367.html

转载请注明原文地址: https://www.6miu.com/read-57774.html

最新回复(0)