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"
相关推荐
心灵宝贝1 天前
Mac 安装 JDK 8u281(JDK-8u281-1.dmg)详细步骤(附安装包)
java·macos·intellij-idea
9***P3341 天前
Git测试框架使用指南
git
侯小啾1 天前
理解计算机网络中的MAC地址
网络·计算机网络·macos·mac
X***48961 天前
Git数据分析应用
git
6***37941 天前
Git安全
git·安全
z***I3941 天前
Git机器学习
人工智能·git·机器学习
坚果派·白晓明2 天前
开源鸿蒙终端工具Termony构建HNP包指导手册Mac版
macos·开源·harmonyos
代码AC不AC2 天前
【Linux】版本控制器Git
linux·git·gitee
Z***25802 天前
Git云原生
git·云原生
h***83932 天前
Git撤销commit操作的3种方法对比
git