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"
相关推荐
qinyia10 小时前
如何彻底卸载macOS上的conda并清理环境变量配置
macos·conda
___波子 Pro Max.12 小时前
Git 2.23新增命令switch使用指南
git
℘团子এ20 小时前
git中,项目怎么更换远程仓库连接地址
git
0wioiw021 小时前
Onesignal(Xcode)
ide·macos·xcode
哈基米~南北绿豆1 天前
虚拟机体验:在Windows/Mac上运行鸿蒙PC开发环境
windows·macos·harmonyos
言之。1 天前
Git Hooks
git
代码AI弗森1 天前
Git Bash 与 PowerShell:定位差异、使用场景与选择建议
开发语言·git·bash
森叶1 天前
Git flow command error: ‘flow‘ is not a git command 问题解决
git
天麓1 天前
git merge 举例
git
AI_56781 天前
Git冲突治理白皮书:智能标记与可视化协同的下一代解决方案
大数据·人工智能·git·机器学习