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"
相关推荐
阳墨余3 分钟前
Git 同时管理 Gitee 和 GitHub 的 SSH 配置实战
git·gitee·github
fengyehongWorld8 小时前
Git 认证凭据管理
git
sudebao点com11 小时前
一次“Google 能打开,FlexTV 打不开”的 DNS 故障排查:从 curl 超时到完整证据链
windows·macos·https·cdn·dns·nslookup·网络排错
暮云星影17 小时前
git版本发布
git·gitee·github·gitea
乌夷17 小时前
Git Flow 分支模型
git
独隅17 小时前
VS Code Git 工作树多分支并行开发实战评测
git
EXI-小洲21 小时前
MacOS 微服务网关双雄:Nacos + Higress 安装与 Dubbo 配置实战
macos·微服务·nacos·dubbo
暮云星影1 天前
git仓库分支管理
git·gitee·github·gitea
EXI-小洲1 天前
MacOS 上使用 IntelliJ IDEA 指定 Main 函数并打包为 JAR 文件
macos·intellij-idea·jar
Albart5752 天前
Docker Desktop最新版安装踩坑全记录(Windows_Mac_Linux)【2026 4.74.0 终版】
linux·windows·macos·docker·环境搭建·踩坑记录