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"
相关推荐
Rabbit_QL2 小时前
【Git基础】03——Git 撤销与回退:改错了怎么办
大数据·git·elasticsearch
无限进步_2 小时前
【C++&string】寻找字符串中第一个唯一字符:两种经典解法详解
开发语言·c++·git·算法·github·哈希算法·visual studio
木下~learning2 小时前
零基础Git入门:Linux+Gitee实战指南
linux·git·gitee·github·虚拟机·版本控制·ubunt
zh_xuan3 小时前
修改远程仓库名以及和本地工程同步
git
读书札记20224 小时前
Git 配置用户名和邮箱 解决 fatal: unable to auto-detect email address 问题
git
qq_411262424 小时前
ESP32-C5 软件配置MAC 地址
macos
鸠摩智首席音效师4 小时前
如何在 MacOS 上安装 PostgreSQL ?
数据库·macos·postgresql
程序员 沐阳4 小时前
Git 二分法精准定位 Bug:从原理到实战,让调试效率起飞
git·elasticsearch·bug
陳10304 小时前
Linux:入门开发工具--Git和GUN调试器
linux·运维·git
淼淼爱喝水5 小时前
Ansible 常用文件模块详解(copy、file、fetch)
chrome·git·github