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"
相关推荐
vistaup18 分钟前
windows git 更新当前目录下所有的文件(非递归)
windows·git
王码码20351 小时前
Flutter for OpenHarmony:Flutter 三方库 algoliasearch 毫秒级云端搜索体验(云原生搜索引擎)
android·前端·git·flutter·搜索引擎·云原生·harmonyos
待续3013 小时前
OpenClaw 安装及使用教程(Windows / macOS / Linux)
linux·windows·macos
Irene19915 小时前
Git 命令汇总表(基于一次完整的 Git 实战经验整理,涵盖从安装配置到日常开发、问题排查的所有常用命令)
git·常用命令
q5431470876 小时前
Redis Desktop Manager(Redis可视化工具)安装及使用详细教程
redis·git·bootstrap
阿正的梦工坊6 小时前
在Mac电脑上如何显示点(.)开头的隐藏文件
macos
素雨迁喜7 小时前
Linux平台下git工具的使用
linux·运维·git
AI-小柒7 小时前
DataEyes 聚合平台 + Claude Code Max 编程实战
android·开发语言·人工智能·windows·python·macos·adb
Irene19919 小时前
Windows环境,VS Code 中 Git 配置指南
git·基础配置
I'm Jie9 小时前
MacOS 使用 pyenv + brew 优雅管理 Python 多版本环境
python·macos·pyenv