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"
相关推荐
qcx2337 分钟前
【AI Engineering · Harness 系列】02 确定性外壳 × 非确定性内核——git push 红线的故事
人工智能·git·prompt·agent·engineering·harness
水云桐程序员39 分钟前
10 分钟 Git 上手教程
git
2601_9583205739 分钟前
【详细版教程】Windows/macOS/Linux 安装 OpenClaw 2.6.6 指南(包含安装包)
linux·运维·windows·macos·小龙虾·open claw一键安装
HackTwoHub1 小时前
可视化未授权访问批量探测工具、支持批量目标、并发扫描、SOCKS5 全局代理、CSV 导出
linux·windows·macos·网络安全·网络攻击模型
Dontla1 小时前
Git三个主要区域介绍(工作区Working Directory、暂存区Index/Staging Area、仓库区Repository)
git
她说可以呀2 小时前
git在Ubuntu的下载和配置用户
git·ubuntu
隔窗听雨眠2 小时前
Git二分法精准定位Bug
git·bug·git bisect
Allen Su3 小时前
【Mac 教程系列第 19 篇】如何将 macOS 中的 Microsoft AutoUpdate 软件从系统中删除
microsoft·macos·autoupdate
丝雨_xrc3 小时前
Minimax M2.7 多模态应用落地实战指南
ide·macos·xcode
weixin_704266053 小时前
IDEA 整合 Git 并上传代码到 CSDN GitCode 超详细教程
git·intellij-idea·gitcode