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"
相关推荐
import_random12 小时前
[git]只有git,没有github, 如何工作
git·github
import_random12 小时前
[git]先创建远程仓库or先创建本地项目
git·github
ddshub_cc13 小时前
Claude Code 接入 DDS Hub:Windows/macOS 配置、验证与报错排查
windows·macos·ai编程·claude·codex·ai模型·aiapi
Linux实战笔记15 小时前
rebase 变基引发提交哈希重写与指针机制分析
git·rebase·提交哈希·分支模型·代码合并
小稀土12316 小时前
私有化研发协同系统并行期:旧 Jira 与新 Git 并存 6 条数据规则
git
Madison-No716 小时前
Git版本控制工具(二)
git
加载力科技17 小时前
Mac解压RAR分卷全攻略-part01part02一键合并
macos·mac 解压 rar 分卷·rar 分卷·part01·mac 解压工具·乐压·分卷合并
2601_9679791219 小时前
Opteryx Python库 macOS版本0.0.0a12
python·macos·1024程序员节·wheel·opteryx·alpha
Brookty20 小时前
Git 与 GitHub|第一阶段:仓库、版本历史与 Git 对象模型(上篇)
git·github
Kimnol1 天前
我的第一次 Git 贡献:从 fork 到合并 PR #3130
git