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"
相关推荐
charlee441 小时前
Git使用经验总结8-Git仓库历史记录清除
git·powershell·敏感信息·仓库重置·历史重写
正经教主2 小时前
【Git】Git05-04:Github分支管理与协作流程
git·github
sean9084 小时前
git filter-repo(优秀的 git repo 历史重写工具) 实战
git·repo·工具
hen3y4 小时前
清理 Git 代码库大文件历史记录
运维·git
小Lu的开源日常5 小时前
踩坑日记:为什么Git 突然 Push 不上去了
git·ssh·github
壕壕5 小时前
Re: 0x03. 从零开始的光线追踪实现-多球体着色
macos·计算机图形学
LZ7工作室6 小时前
MAC编程:在MACOS安装和使用 Git 的方法
网络·git·macos·github·个人开发
T***16078 小时前
Git增强现实案例
git·ar
白玉cfc10 小时前
【iOS】多线程基础
macos·ios
Arva .10 小时前
git常用
git