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"
相关推荐
I烟雨云渊T6 分钟前
2025年的WWDC所更新的内容
macos·ios·wwdc
Fatbobman(东坡肘子)6 分钟前
WWDC 2025 开发者特辑 | 肘子的 Swift 周报 #088
开发语言·macos·ios·swiftui·ai编程·swift·wwdc
vastgrassland6 分钟前
从WWDC看苹果产品发展的规律
macos·ios·wwdc
江梦寻1 小时前
软件工程教学评价
开发语言·后端·macos·架构·github·软件工程
survivorsfyh3 小时前
Xcode 16 集成 cocoapods 报错
macos·xcode·cocoapods
getapi5 小时前
flutter把 pubspec.yaml 中的name改成了新的值
flutter·macos·cocoa
牧野星辰6 小时前
.gitignore文件的规范
git·github
Smile_Gently9 小时前
Mac 系统 Node.js 安装与版本管理指南
macos·node.js
Yale曼陀罗12 小时前
如何快速删除谷歌浏览器在mac启动台生成的网页图标
macos
二个半engineer12 小时前
GitLab Web 界面创建分支后pathspec ... did not match any file(s)
git·gitlab