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"
相关推荐
嚴寒几秒前
Mac 安装 Dart & Flutter 完整开发环境指南
前端·macos
眼小博3 小时前
多人协作Git开发流程指南
git
lpfasd12310 小时前
git-团队协作基础
chrome·git·elasticsearch
John Song12 小时前
git多个账号管理
git·github
CV_J13 小时前
解决Git 冲突后本地提交丢失/未推送问题
git
__Witheart__13 小时前
Git 某个分支恢复到某个特定的 commit 状态
git
开开心心loky13 小时前
[iOS] GCD - 线程与队列
macos·ios·objective-c·cocoa
XU磊26014 小时前
Git 实现github仓库管理-删除指定目录下的所有文件并保留目录结构
git·github
冷冷的菜哥16 小时前
21款m1 max升级到macOS 14——Sonoma
macos·苹果·sonoma·macos系统升级
laocaibulao16 小时前
mac电脑composer命令如何指定PHP版本
macos·php·composer