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"
相关推荐
ShineWinsu6 小时前
对于Git:基础操作的超详细保姆级解析
linux·c++·git·面试·备份·管理·版本控制器
沉迷...7 小时前
Git skip-worktree 使用笔记(本地忽略配置文件)
javascript·git
解道Jdon9 小时前
JDK 27发布:紧凑对象头、G1默认、量子安全TLS
ide·windows·git·svn·eclipse·github·visual studio
大象AI共学10 小时前
想在手机上读 Obsidian?Mac → iPhone / 安卓的零成本方案
macos·智能手机·iphone
天天喝旺仔12 小时前
Git 内部原理深度解析:从 blob/tree/commit 对象到 packfile 与垃圾回收
数据结构·数据库·git·算法·哈希
艾莉丝努力练剑12 小时前
【Git:综合复盘】Git 原理与使用
大数据·人工智能·git·elasticsearch·面试
sysinside1 天前
如何创建可引导的 macOS Golden Gate 27 安装介质
macos
ShineWinsu1 天前
对于Git:远程操作的超详细保姆级解析
linux·git·gitee·github·远程仓库·分布式版本控制系统·远程操作
梦帮科技1 天前
从 Guest 到 Platinum:Prompt 配额、API Key 与访问控制的安全闭环
javascript·git·架构·node.js·reactjs·html5·visual studio
Dr.Buho1 天前
macOS 27 升级教程:兼容机型、三种安装方法与降级提示
经验分享·macos