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"
相关推荐
超梦dasgg5 小时前
工作中 Git 完整使用指南(职场实战版)
git
Ws_5 小时前
Git + Gerrit 第七课:stash 临时保存工作区修改
git
enjoywindstorm5 小时前
git从入门到精通
git
大码青年5 小时前
Pentaho Data Integration 完整安装指南 MacOS M5 - 最新版下载地址 pdi-ce-11
macos
专注VB编程开发20年7 小时前
swift,object-c同名函数重载
macos·objective-c·cocoa
Adorable老犀牛10 小时前
Git 发布正式版本的一个专属的硬核功能,叫做 打标签(Tag)。
git
我先去打把游戏先11 小时前
Ubuntu虚拟机(服务器版本)Git卸载完全教程——彻底移除与清理配置
服务器·git·单片机·嵌入式硬件·物联网·ubuntu·51单片机
一个人旅程~12 小时前
如何让bootcamp-win10中的触摸板像macbook中一样丝滑原生效果?
windows·经验分享·macos·电脑
欧阳天羲12 小时前
AI智能水枪完整开发攻略
人工智能·macos·xcode
不做无法实现的梦~12 小时前
Git Clone 使用 Watt/Steam++ 加速时报证书错误的原因与解决方法
大数据·git·elasticsearch