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"
相关推荐
liuyao_xianhui7 小时前
版本控制器git--gdb/cgdb
linux·运维·服务器·git
mixboot8 小时前
macOS Homebrew 安装 Nmap
macos·nmap
徐同保8 小时前
如何使用GitKraken把git项目迁移到另一个平台,并保存所有提交记录,例如把github上的项目,迁移到gitee
git·gitee·github
高小秋9 小时前
项目开发使用 git工作流插件 -- jgitflow开发实践
git
tealcwu9 小时前
【软件工程】浅析Git message, version, changelog之间的关系
git
五号厂房11 小时前
Git Worktree 使用指南
git
秦jh_12 小时前
【git】企业级开发模型
git
Dream-Y.ocean12 小时前
告别设备束缚!网易 UU 远程 Mac 被控体验:免费高清 + 多场景丝滑,跨端办公刚需神器
macos
y***548813 小时前
Git在开源项目中的协作
git
老友記18 小时前
git cherry-pick使用
git