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"
相关推荐
咋吃都不胖lyh7 小时前
提交(Commit)到本地的 Git 仓库,然后才能推送(Push)到远程的 Git 仓库
git
Lvan的前端笔记8 小时前
python:Mac 系统 uv 完整安装+入门实战
python·macos·uv
__zRainy__9 小时前
VS Code 自动同步如何重写 Git 历史:一次重复合并冲突的排查与恢复
git
IT码农-爱吃辣条10 小时前
AI Codeview 安装与使用教程
git·ai
pop_xiaoli10 小时前
【iOS】离屏渲染
macos·ios·objective-c·cocoa
鸠摩智首席音效师10 小时前
如何在 macOS 上创建 React.js 应用程序 ?
前端·react.js·macos
司南-704910 小时前
怎么使用git打包tag,并推送到远程仓库
git
考虑考虑10 小时前
git中的tag
git·gitlab·github
REDcker11 小时前
Git浅克隆详解与实践
大数据·git
养肥胖虎21 小时前
Git提交规范笔记:feat和fix到底该怎么写
git·conventionalcommits