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"
相关推荐
朝阳58142 分钟前
如何用 AI 自动生成规范的 Git 提交信息:从暂存区 diff 到 Conventional Commit
人工智能·git
hudawei9961 小时前
有未保存的修改,不能切换分支
git·git stash·stash
康一夏1 小时前
Git Commit 规范实践:Angular Commit 规范 + Commitlint 自动化验证
git·自动化·commit msg·commit规范
HackTwoHub3 小时前
BurpSuite2026.8专业(稳定版)下载Windows/Linux/Mac支持Java21以上(新增Burp AT智能体)
linux·运维·服务器·安全·macos·网络安全·自动化
海鸥两三3 小时前
Mac电脑使用 Tabby 部署前端项目到阿里云服务器完整教程
前端·macos·阿里云
LayZhangStrive5 小时前
Git - 使用IDEA和git上传本地项目到Gitee远程仓库
git·gitee·idea
云泽8086 小时前
Git 版本控制系统(上):架构原理与操作入门
linux·git·架构
绝世唐门三哥6 小时前
Git - git stash 语法演进与实战指南
前端·git
阿沐沐,7 小时前
Claude Code 安装教程:Windows、WSL 2 与 macOS
windows·macos
梨想橙汁7 小时前
Git 分支详解:创建切换、合并分支、冲突解决实战
前端·git