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笔记---远程仓库的创建与基本操作
笔记·git
9***Y483 小时前
终于解决了!Git拉取代码冲突的处理
git
南屿欣风4 小时前
Idea中Git切换分支,如何确保代码不丢失。
git
不一样的故事1264 小时前
将 Git 远程仓库的地址从 HTTP 修改为 SSH,
git·http·ssh
n***i955 小时前
终于搞定了!Git分支回滚的正确操作
git
A***27955 小时前
终于搞定了!Git拉取代码时权限被拒绝
git
秦jh_5 小时前
【git】多人协作
git
小坏讲微服务8 小时前
Docker Compose搭建Git仓库私服上传微服务
分布式·git·docker·微服务·容器·springcloud·springalibaba
FreeBuf_9 小时前
高度复杂的macOS DigitStealer采用多阶段攻击逃避检测
macos·m2芯片
七号练习生.c16 小时前
Git常用命令速查
大数据·git