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"
相关推荐
阿寻寻5 小时前
【云原生技术】git checkout -- . 应该用在切分之前还是之后?
git
周杰伦fans6 小时前
Git 推送实战:冲突解决与强制推送
git
eppen8 小时前
macOS 快捷键修改
macos
郁大锤12 小时前
macOS 终端 SSH 到 Linux 后快捷键失效解决方法
linux·macos·ssh
Beyond欣13 小时前
Git 踩坑记录
git
没有bug.的程序员14 小时前
分布式配置深潜:Spring Cloud Config 与 Git 集成内核、版本回滚机制与多环境治理实战指南
java·分布式·git·spring cloud·分布式配置·版本回滚
阿捏利14 小时前
详解Mach-O(十三)Mach-O __TEXT
macos·ios·c/c++·mach-o
Laughtin15 小时前
macos的python安装选择以及homebrew python的安装方法
开发语言·python·macos
猫头虎16 小时前
OpenClaw相关的开源AI项目汇总大全:本文涵盖近期所有OpenClaw相关的GitHub高星star热门项目
运维·人工智能·macos·docker·容器·开源·github
JTfAbUGXr16 小时前
Smart200PL与42块安科瑞多功能电度表Modbus RTU通讯程序探索
git