从Git删除文件,而无需在本地和远程删除它们 [英] Remove file from Git without deleting them locally and remotely

查看:134
本文介绍了从Git删除文件,而无需在本地和远程删除它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于Wordpress intall的存储库,当前其中包含所有Wordpress文件.

I have a repository for a Wordpress intall that currently has all the Wordpress files included.

我已将.gitignore更新为仅包含主题文件夹,但是当我推送到暂存服务器时,它将删除所有文件.

I have updated my .gitignore to only include the theme folder but when I push to my staging server it deletes all the files.

我需要将所有文件都保存在本地和服务器上,但我希望停止跟踪它们并将其从存储库中删除,理想情况下,历史记录应保持不变.

I need to keep all the files both locally and on the server, but I want them to stop being tracked and removed from the repository, Ideally with the history still intact.

预先感谢

推荐答案

服务器具有存储库的副本,因此,如果从存储库中删除任何内容,它也将从服务器的存储库中删除(在您推送之后).

The server has a copy of the repository, so if you remove anything from the repository it will be removed from the server's repository as well (after you push).

但是,您可以将git设置为假定文件未更改.这样会将它们保留在存储库中,但是git将停止检测对它们的新更改.

However, you can set git to assume the files are unchanged. This will keep them in the repository, but git will stop detecting new changes to them.

这篇关于从Git删除文件,而无需在本地和远程删除它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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