如何从Git裸远程存储库中删除文件? [英] How to delete files from git bare remote repository?

查看:69
本文介绍了如何从Git裸远程存储库中删除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个远程裸git存储库.

I have a remote bare git repository.

一个新的开发人员克隆了它,但是他没有正确配置的.gitignore文件,因此他错误地将一些不需要的文件推送到了远程服务器中.当我进行更改并合并时,我得到了这些以前未跟踪的文件.其他人也从远程撤消了更改,并且还拥有了这些不需要的文件.

A new developer cloned it, but he didn't have a properly configured .gitignore file, so he mistakenly pushed some unwanted files into the remote. When I pulled the changes and merged, I got these previously untracked files. Others have also pulled the changes from the remote and have these unwanted files as well.

如何从远程存储库以及其他所有人的远程/起源/分支删除这些文件?

How do I delete these files from the remote repository, and everyone else's remote/origin/branches?

推荐答案

这是一个三步过程:

  1. 从存储库副本中删除文件(使用 git rm 或通过从您的历史记录中完全清除这些文件,具体取决于这些文件的重要性永远不会出现在存储库中)
  2. 使用 git push --force 将更改推回远程存储库.
  3. 让所有人都知道他们可以重新拉出存储库-这将需要 git rebase 他们最后一次知道的 good 提交的工作.
  1. Remove the files from your copy of the repository (either with git rm or by totally purging these files from your history depending on how important it was that these files never be in the repository in the first place)
  2. Push your changes back to the remote repository using git push --force.
  3. Let everyone know that they can re-pull the repository - this will require a git rebase of their work on the last know good commit.

最后一步,您可能还想将.gitignore文件添加到存储库中,以便在克隆存储库时,所有正确的文件都将被忽略.

As a last step you may also want to add the .gitignore file to the repository so that when the repository is cloned all the right files get ignored.

这篇关于如何从Git裸远程存储库中删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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