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"
相关推荐
摆烂z2 小时前
AI同时完成多个功能(Git WorkTree)
git
开开心心就好6 小时前
解决打印机共享难题的实用工具
人工智能·vscode·游戏·macos·音视频·语音识别·媒体
Digitally6 小时前
如何顺畅将传音 Infinix 数据传输到 Mac?
macos
___波子 Pro Max.7 小时前
Git Worktree 可视化理解指南
git
happymaker06269 小时前
git使用快速入门
git
不做超级小白9 小时前
从零到可用:在手机上用 Termux + Git + Obsidian 打造稳定同步环境(踩坑全记录)
git·智能手机
凡客丶9 小时前
Git安装与使用保姆教程【超详细】
git
android_cai_niao9 小时前
给Git项目添加多个远程仓库
git·gitee·github
胡小禾9 小时前
多账号下git自动切号
git
zhensherlock10 小时前
Protocol Launcher 系列:Working Copy 提交与同步全攻略
javascript·git·typescript·node.js·自动化·github·js