如何在不删除磁盘的情况下git rm文件? [重复]

本文翻译自:How do I git rm a file without deleting it from disk? [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

The command removes the file in my system. 该命令将删除系统中的文件。 I meant it to remove only the file from Git-repository. 我的意思是它只从Git-repository中删除文件。

How can I remove the file from a Git repository, without removing the file in my system? 如何在不删除系统中的文件的情况下从Git存储库中删除该文件?


#1楼

参考:https://stackoom.com/question/5LC0/如何在不删除磁盘的情况下git-rm文件-重复


#2楼

According to "git help rm", 根据“git help rm”,

git rm --cached file

should do what you want. 应该做你想做的事。


#3楼

I tried experimenting with the answers given. 我试着尝试给出答案。 My personal finding came out to be: 我个人的发现是:

git rm -r --cached .

And then 然后

git add .

This seemed to make my working directory nice and clean. 这似乎使我的工作目录变得干净整洁。 You can put your fileName in place of the dot. 您可以将fileName放在点的位置。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值