从Git存储库中删除文件,而不从本地文件系统中删除它 [英] Remove a file from a Git repository without deleting it from the local filesystem
本文介绍了从Git存储库中删除文件,而不从本地文件系统中删除它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
* log
添加到我的 .gitignore
中,现在我想从存储库中删除日志文件。 git rm mylogfile.log
会从存储库中删除文件,但也会从本地文件系统中删除它。
如何从
解决方案
对于单个文件:
git rm --cached mylogfile.log
对于单个目录:
git rm --cached -r mydirectory
My initial commit contained some log files. I've added *log
to my .gitignore
, and now I want to remove the log files from my repository.
git rm mylogfile.log
will remove a file from the repository, but will also remove it from the local file system.
How can I remove this file from the repo without deleting my local copy of the file?
解决方案
For single file:
git rm --cached mylogfile.log
For single directory:
git rm --cached -r mydirectory
这篇关于从Git存储库中删除文件,而不从本地文件系统中删除它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文