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"
相关推荐
大柏怎么被偷了21 分钟前
【Git】企业级开发模型
git
Garfield200535 分钟前
Git 分支拓扑实践
git·拓扑
DKNG35 分钟前
【Windows Host】 hosts配置增加访问github流畅度
人工智能·git·github
一个很帅的帅哥3 小时前
git命令大全
大数据·git·elasticsearch
凯子坚持 c3 小时前
Git 远程仓库操作与深度进阶指南
git
勇敢牛牛_4 小时前
RustRover 2025.3 在WSL中GIT操作十分缓慢的问题
git·rust·rustrover
编程小白gogogo5 小时前
创建git仓库并推送苍穹外卖初始项目
git
cat_milk5 小时前
【git】git的基础使用二
git
XiaoHamao6 小时前
Git 核心分区全解析
git
XiaoHamao6 小时前
git stash:优雅处理未完成的代码改动
git