【GIT】-- gitignore已经提交的文件

步骤 1️⃣:先把规则写进 .gitignore

例如:

gitignore 复制代码
build/
*.elf
*.bin
*.map

步骤 2️⃣:把"已跟踪文件"从索引中移除(不删本地文件)

bash 复制代码
git rm --cached build/output.elf

或者整个目录:

bash 复制代码
git rm -r --cached build/

⚠️ --cached 非常关键:

  • 只从 Git 索引删除
  • 不会删除你本地的文件

步骤 3️⃣:提交一次

bash 复制代码
git commit -m "chore: ignore build artifacts"

步骤 4️⃣:验证

bash 复制代码
git status
相关推荐
爱学英语的程序员1 天前
Git 提交 LF will be replaced by CRLF the next time Git touches it 报错
git
qq_339191141 天前
服务器git pull每次都要输入密码,linux 设置git登录,linux设置git只输入一次账户密码
git
一颗小行星!1 天前
快速理解 Git submodule
git
A-Jie-Y1 天前
Git基础-核心概念与常用命令
git
夜珀1 天前
Git基础修炼手册:在AtomGit上玩转版本控制
git
golang学习记1 天前
Zed IDE官宣新招:Git Graph 正式支持!
ide·git
要记得喝水1 天前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash
AI_Claude_code1 天前
专栏导论:开源项目贡献的价值与Git工作流全景图
git·开源
never forget shyang1 天前
CCS20.2.0使用教程
c语言·git·单片机
lifewange2 天前
常用的Git命令有哪些?
git