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"
相关推荐
甲枫叶5 小时前
【claude】Claude Code正式引入Git Worktree原生支持:Agent全面实现并行独立工作
java·人工智能·git·python·ai编程
0xwang8 小时前
Deepin25社区版修改Git编码
git
lichao8904279 小时前
MacOS 上部署 OpenClaw 的全界面操作方案
macos·docker·容器
第七序章15 小时前
【Linux学习笔记】git三板斧
linux·运维·服务器·笔记·git·学习
三无少女指南15 小时前
开发者环境配置最佳实践:编辑器Cursor ,VS Code的上位体验实现 AI 与 WSL 联动
运维·c语言·数据库·windows·git·编辑器
美酒没故事°16 小时前
mac电脑安装OpenClaw步骤
人工智能·macos
Rhystt17 小时前
furryCTF 题解|Web方向|保姆级详解|固若金汤、DeepSleep
git·python·安全·web安全·网络安全
头发那是一根不剩了1 天前
Git 常用命令
git
x-cmd1 天前
[x-cmd] x git - Git 命令增强工具
git·终端·命令行·x-cmd