ios文件用git进行管理时,使用gitignore进行文件忽略

来源:互联网 发布:使用网络的注意事项 编辑:程序博客网 时间:2024/05/31 06:22

最近一个ios项目 使用git进行版本控制,但是发现忘记添加.gitignore

每次项目提交都会有每隔几秒xcuserstate的改变,而这个文件是不需要提交的 ,所以需要添加.gitignore对这个文件进行忽略

方法如下  xcode自带git工具  pereference-compnets  下载命令行  

切换到git控制的程序目录  从别处拷贝 或者自己创建一个.gitignore  内容如下

Xcode

/Demo/Demo-Info.plist
.DS_Store
/build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap

CocoaPods

Pods

保存之后,你会发现这个文件并未生效  

原因是因为.ignore是后来加进来的 local cache里面记录的这个文件是不忽略的 所以需要进行缓存清除 

$ git rm --cached iLedger.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate$ git commit -m "Removed the stupid strange file that shouldn't be tracked"$ git push
高兴

0 0