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"
相关推荐
H Journey16 小时前
Git 教程
git
1telescope1 天前
MacBook 安装 nvm 管理 Node.js 多版本教程
macos·node.js
1telescope1 天前
MacBook 安装 Oh My Zsh 完整教程
macos·mac
蜜汁小强1 天前
macOS 上的git代理配置在哪里
git·macos·代理模式·proxy模式
钟佩颖1 天前
Git .
git
蜜汁小强1 天前
macOS 上升级到 python 3.12
开发语言·python·macos
上天_去_做颗惺星 EVE_BLUE1 天前
Android设备与Mac/Docker全连接指南:有线到无线的完整方案
android·linux·macos·adb·docker·容器·安卓
goodmao1 天前
【macOS】【磁盘空间整理】查看大文件夹
macos
七夜zippoe1 天前
Cython终极性能优化指南:从Python到C++的混合编程实战
c++·python·macos·cython·类型系统·内存视图
Zhongyi_Li1 天前
git merge的一些记录
git