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"
相关推荐
半夏微凉半夏殇2 小时前
git add . 是否会包含.o、.so、.ko文件?深度解析与避坑指南
git
牟同學2 小时前
Git 实战场景操作大全(可直接落地)
git
不做无法实现的梦~3 小时前
使用ros2跑mid360的fastlio2建图
git·单片机·嵌入式硬件·gitcode
Three~stone4 小时前
MacOS 各个版本相关镜像(dng和iso镜像文件)
macos
爱喝矿泉水的猛男5 小时前
如何测试鼠标是否支持mac mouse fix
macos·计算机外设
长沙红胖子Qt5 小时前
SVN培训笔记(二):使用sourceTree通过git桥接管理svn项目
git·svn·sourcetree·sourcetree管理svn
半夏微凉半夏殇6 小时前
从多仓库到单仓库:如何高效迁移并统一管理多个Git项目
git
__万波__7 小时前
解决警告“..LF will be replaced by CRLF the next time Git touches it“
git
Software攻城狮7 小时前
git报错处理
git
Navicat中国8 小时前
Navicat Premium MacOS:原生或通过 Rosetta 运行教程
数据库·macos·oracle·navicat·rosetta