git (全局)忽略文件

移除已跟踪的 .DS_Store 文件

# 移除所有 .DS_Store 文件
git rm --cached .DS_Store
git rm --cached all-files/.DS_Store

# 或者递归移除所有 .DS_Store 文件
git rm -r --cached **/.DS_Store

提交更改

# 添加 .gitignore 文件
git add .gitignore

# 提交更改
git commit -m "Add .gitignore to ignore .DS_Store files"

全局忽略(可选)

# 创建全局 gitignore 文件
echo ".DS_Store" >> ~/.gitignore_global

# 配置 Git 使用全局 gitignore
git config --global core.excludesfile ~/.gitignore_global

 

posted @ 2025-09-07 13:26  xiaobingch  阅读(14)  评论(0)    收藏  举报