macos git上传通过全局设置不上传.DS_Store

文章目录

场景

最近换了mac,代码上传很多.DS_Store文件。 .DS_Store 文件是 macOS 系统中自动生成的隐藏文件,用于在文件夹中存储与 Finder 界面相关的元信息。

下面通过全局设置避免git上传.DS_Store

全局解决方案

  1. 创建全局忽略文件
sh 复制代码
touch ~/.gitignore_global
  1. 将 .DS_Store 添加到全局忽略文件:
sh 复制代码
echo ".DS_Store" >> ~/.gitignore_global
  1. 配置 Git 使用全局忽略文件
sh 复制代码
git config --global core.excludesfile ~/.gitignore_global

清理项目中已有的.DS_Store

sh 复制代码
git rm --cached .DS_Store

git commit -m "删除 .DS_Store"
相关推荐
老李IT笔记16 小时前
激活锁状态怎么检测:三个入口,四种返回值,一份排查顺序
git·智能手机·github
Joecien16 小时前
【2026实测】百炼 CLI 托管 Agent 教程:bl managed-agent 配置校验、版本回滚与变更预演(附完整命令)
人工智能·git·阿里云·知识图谱·agi
行者-全栈开发1 天前
【码动四季·秋】从 commit 到发版全自动:Conventional Commits + semantic-release 发布流水线实战
git·ci/cd·自动化发布·atomgit·semantic-releas·语义化版本自动化·git 提交规范落地
yqj2341 天前
ESP32-S3中小智项目优化内容
ide·macos·xcode
Mininglamp_27182 天前
Cider量化配置与性能调优:在M系列Mac上压榨Mano-P的每一点推理性能
macos
xuefuhe2 天前
MacOS EAGAIN无法打开terminal
macos
Flynt2 天前
Claude Code 103 秒删掉 4.8 万个文件之后,我把自己的仓库"删"了一遍:git 能救的比你想的少
git·ai编程·claude
csdn2015_2 天前
git 可以修改已经push上去的commit说明吗
git
传奇开心果编程3 天前
【SwiftUI入门练中学】第7课 动画与手势:让界面更灵动
学习·macos·ui·ios·swiftui·swift