Git配置.gitignore忽略文件

1.首先要在项目目录下添加或者创建一个.gitignore文件

touch .gitignore

注意:.gitignore文件是隐藏文件,如果你在目录下创建后却看不到,请在终端中输入一下命令打开隐藏开关
此命令打开显示隐藏文件
defaults write com.apple.finder AppleShowAllFiles -bool true
此命令关闭显示隐藏文件
defaults write com.apple.finder AppleShowAllFiles -bool false
命令运行之后需要重新加载Finder:快捷键option+command+esc,选中Finder,重新启动即可。或者在强制退出中重新启动Finder。

2.打开文件

open .gitignore

3.添加需要被忽略的文件,这是一个.gitignore配置文件

# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
#*.xcworkspace
#!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.xcuserstate
# Pods - for those of you who use CocoaPods
#Pods

4.若没有生效,使用以下代码删除当前缓存

git rm —cached xxx.project/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "add file to .ignore file"
git push

5.也可以打开文件夹,按以上路径直接找到UserInterfaceState.xcuserstate文件并删除

6.测试:再提交就显示没有药添加的文件了

git add .
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容