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"
相关推荐
月初,21 小时前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
李少兄1 天前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
REDcker1 天前
macOS「系统数据」暴涨到 几百GB?一篇文章教你安全清理(含排查顺序)
macos
sysinside1 天前
macOS Sequoia 15.7.2 (24G325) 正式版 ISO、IPSW、PKG 下载
macos·sequoia
只是有点小怂1 天前
macOS 没有像 Windows 上的 MobaXterm 的工具
macos
github.com/starRTC1 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github
小雨青年1 天前
环境准备 Windows Mac 下 Docker Desktop 的安装与镜像源加速
windows·macos·docker
数据知道1 天前
一文掌握 MongoDB 详细安装与配置(Windows / Linux / macOS 全平台)
linux·数据库·windows·mongodb·macos
知1而N1 天前
电脑上运行APK文件(Android应用程序包),需要借助特定的软件或功能,因为Windows/macOS/Linux系统无法原生直接运行安卓应用
android·macos·电脑