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"
相关推荐
ssshooter7 小时前
彻底搞懂 SSH 与 Git 的“幕后交易”
git·github·全栈
Asurplus11 小时前
Centos7安装Git环境
git·centos·yum·dnf
m0_7431251312 小时前
claude --version 报错Claude Code on Windows requires git-bash (https://git-scm.com/downloads/win).
开发语言·git·bash
AntoineGriezmann13 小时前
Git:新建功能分支并解决 Merge 冲突
git
梁辰兴14 小时前
计算机网络基础:以太网的 MAC 层
网络·计算机网络·macos·计算机·mac·以太网·梁辰兴
Sylus_sui15 小时前
Git快速创建并推送新分支
git
悠悠子衿1213816 小时前
Claude+VSCODE配置git导致频繁弹出git bash 的CMO窗口解决方法
ide·git·vscode
QC七哥17 小时前
伪造git提交记录生成点阵字符
git·github
HilariousDog17 小时前
git仓库中克隆文件同时保存line history / 行提交历史的方法介绍
git
TimberWill18 小时前
GitHub Copilot 一键生成中文commit提示语规则设置
git·github