blog/_posts/git/rm-cache-file.md
2024-05-12 14:14:45 +08:00

28 lines
624 B
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 🌲Git删除已经提交在远程仓库中的忽略文件
date: 2023-11-18
tags: Git
---
很多时候我们在git库中不小心把应该忽略的文件或目录提交远程库中比如`.idea``.ivscode`等。把远程删除,本地不发生变化,以下操作即可:
### 1.使用git rm 命令
**git rm -r --cached** 要删除的文件名或目录,如:
```sh
git rm -r --cached .idea #--cached 只删远程仓库的文件,不会删除本地的
```
### 2.提交操作记录描述
```sh
git commit -m '删除XX文件'
```
### 3.推送到远程仓库
```sh
git push -u origin <branch_name>
```