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"
相关推荐
篮子里的玫瑰14 小时前
Git管理工具深度解析:从原理到企业级落地的全链路讲解
git·vscode
高兴就好(石1 天前
Mac使用llama.cpp
macos·llama
@PHARAOH1 天前
WHAT - git worktree 概念
前端·git
星辰即远方1 天前
UITableView操作拓展
macos·ios·xcode
qinqinzhang1 天前
代码管理仓库(Git Submodules + Worktree)
git
刘某某.1 天前
macOS 终端美化完整教程(Ghostty + Zsh + Starship Catppuccin Powerline)
macos
咦呀1 天前
macOS 上 SVN 报错 "SQLite 编译为 X.XX,运行时为 X.XX" 的完整解决方案
macos
lilili也1 天前
Git、VScode、GitLab
git·vscode·gitlab
拥春飞翔1 天前
AI 生成测试用例:测试知识库选「开源向量库」还「Git+Markdown」?
人工智能·git·测试用例
普修罗双战士1 天前
高效使用 Git:从入门到精通的实战指南
java·git