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"
相关推荐
李永奉1 小时前
Git和GitHub-Git 管理的版本数据到底保存在哪个文件夹里?
git·github
Mortalbreeze1 小时前
Git 基础篇(二):本地仓库管理与常用操作
git
RobinDevNotes2 天前
24GB Mac 做数字人:声音放本地,画面租云端
人工智能·python·macos·开发工具
武昌库里写JAVA2 天前
SpringBoot+Vue 项目介绍
java·javascript·git·sql·ai
oil欧哟4 天前
Oil Studio 的产品思路与日常使用方式:在 Mac 上录口播演示,并接入 AI Agent 精剪与自动录屏
人工智能·macos
Hvitur5 天前
Git - 多分支合并
git·github
考虑考虑5 天前
git刷新远程分支列表
git·后端·gitlab
AI大模型-小华5 天前
Codex 自动测试怎么用?从生成测试用例到修复失败用例
git·测试用例·ai编程·软件开发·codex·chatgpt pro·codex cli
小毛球.6 天前
第 3 篇:IDEA 最新版下载与完整安装教程(Mac)
java·macos·intellij-idea·idea
七分辣度6 天前
GitHub/Git 常用命令及使用场景
git·github