记录一次给iOS 工程添加.gitignore文件

新建了一个iOS工程,修改过代码之后,提交发现有一些自己不想要提交的内容

如下图,里面有.DS_Store文件,还有xcsuserstate文件,

这个时候需要添加忽略文件

首先在工程文件夹中执行 touch .gitignore 创建忽略文件,如果创建过之后

看不到文件,则是没有展示隐藏文件,执行cmd + shift + .就可以看到了

然后编辑如下

复制代码
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace

#CocoaPods
Pods
!Podfile
!Podfile.lock

然后删除记录

复制代码
git rm -r --cached .

添加修改

复制代码
git rm -r --cached .

提交修改

复制代码
git commit -m "修改gitignore文件"

推到远端

复制代码
git push

会产生这样的一个删除提交

相关推荐
hurrycry_小亦10 小时前
苹果WWDC 2026前瞻:Ferret-Pro端侧大模型即将亮相|小亦之闻|AI 编程三日速递!(5月26日~5月28日)
macos·ios·wwdc
UTF_814 小时前
一次NSMutableAttributedString误用的思考
ios·面试·github
wh_xia_jun14 小时前
Git 分支合并操作备忘录
git
满天星830357715 小时前
【Git】原理及使用(三)(分支管理)
linux·git
人月神话-Lee18 小时前
【图像处理】Core Image 与 GPU 渲染管线——让滤镜飞起来
图像处理·人工智能·ios·chatgpt·ai编程·swift·gpu
像风一样的男人@19 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉20 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞1 天前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
夏天的峰没有风1 天前
Typora+gitcode+picgo搭建免费图床
开发语言·ios·swift
xlq223221 天前
7.git
git