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"
相关推荐
洋仔1 小时前
Git 底层原理系列 · 第8讲 — HEAD 与 detached HEAD
git·开源
洋仔1 小时前
Git 底层原理系列 · 第4讲 — `git add` 与 `git commit` 底层做了什么
git·开源
猫咪老师QAQ3 小时前
基于 Git Flow 的团队协作与发布流程实践
git
caicai_xiaobai3 小时前
分享一个访问Git Hub的好方法
git
Joy T3 小时前
【Web3】跨链资金池与消息路由:CCIP 智能合约集成实战与权限收束
git·web3·node·智能合约·hardhat
難釋懷5 小时前
Nginx虚拟主机
git·nginx·github
moMo5 小时前
# Git 入门—代码仓库的使用
git·github
一路向北he6 小时前
git仓库创建新分支,上传文件
git
zandy10117 小时前
2026 主流技术栈:hermes agent多环境安装配置:Windows/Mac/Linux
linux·windows·macos
2501_916008897 小时前
Mac 上生成 AppStoreInfo.plist 文件,App Store 上架
android·macos·ios·小程序·uni-app·iphone·webview