git 删除已提交到远程仓库的文件

385 阅读1分钟

问题

先提交了 代码, 后写了 .gitignore 或者 在 .gitignore 新添加了 需要过滤的文件

# 1.同步远程仓库, 避免冲突
git pull

# 2.在本地项目目录下删除缓存
git rm -r --cached .

# 3.重新添加所有文件到本地仓库
git add .

# 4.添加commit
git commit -m "delete filter file"

# 5.提交到远程库
git push