从存储库中删除文件,但保留在本地 [英] Remove file from the repository but keep it locally

查看:86
本文介绍了从存储库中删除文件,但保留在本地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想在远程存储库中删除的文件夹。我想将其删除,但将文件夹保存在我的电脑中

rm --cached -r somedir

会暂时删除目录,但不会触及任何内容在磁盘上。这也适用于一个文件,如:

  git rm --cached -r somefile.ext 

之后,您可能需要添加 somedir / somefile.ext 添加到 .gitignore 文件中,以便git不会尝试添加它。


I have a folder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer

解决方案

git rm --cached -r somedir

Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like:

git rm --cached -r somefile.ext

Afterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn't try to add it back.

这篇关于从存储库中删除文件,但保留在本地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆