git Git清除远程存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7451534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:01:07  来源:igfitidea点击:

Git clear remote repository

git

提问by Andrzej Gis

If I push a bad initial commit (or more than one) to a remote repository and want to just clear it / destroy it - can I do it by a command?

如果我将错误的初始提交(或多个)推送到远程存储库,并且只想清除它/销毁它 - 我可以通过命令来完成吗?

It's important to totally remove it from server so it doesn't use disk space.

将它从服务器中完全删除很重要,这样它就不会使用磁盘空间。

E.G. Today I pushed a whole Visual Studio project with included dlls, sdfs and so on. Firstly this files are quite big, secondly some of them are modified by VS of other developers and than can't be merged. This made me google a little bit and I found out these files should be ignored. But the first commit already clutters my repository. I want to remove this and free the disk space.

EG 今天我推送了一个包含 dll、sdfs 等的整个 Visual Studio 项目。首先这个文件相当大,其次其中一些文件被其他开发人员的VS修改过,无法合并。这让我谷歌了一下,我发现这些文件应该被忽略。但是第一次提交已经使我的存储库变得混乱。我想删除它并释放磁盘空间。

It's possible to remove git repo and add it again via host's website (assembla), but this doesn't sound like solution to me.. Is there a more professional way?

可以删除 git repo 并通过主机的网站 (assembla) 再次添加它,但这对我来说听起来不是解决方案..有更专业的方法吗?



UPDATE:

更新:

I tried suggestions from the answer below but it didn't work: 'git push -f' 'git push --force' 'git push origin -f' 'git push origin --force' resulted in:

我尝试了以下答案中的建议,但没有奏效:'git push -f' 'git push --force' 'git push origin -f' 'git push origin --force' 结果:

$ git push --force
Counting objects: 19, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (19/19), 6.85 KiB, done.
Total 19 (delta 3), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull fir
)
To [email protected]:xxxxx.git
 ! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:xxxxx.git'

回答by Andy

You can force push the "correct" repo with git push -f. Depending on the host, the loose objects will be cleaned up when git gcis ran. update: According to thisyou can't force the git gcin assembla.

您可以使用git push -f. 根据主机的不同,松散的对象将在git gc运行时被清理。 更新:根据this你不能强制git gc在汇编。

If you want them cleaned up immediately and assembla doesn't allow you to force a git gc, the other option is to delete the repo and push a new one.

如果您希望它们立即清理并且汇编不允许您强制 a git gc,另一种选择是删除 repo 并推送一个新的。

In addition, as Ryan stated in the comments, be sure to let everyone know that may have cloned the repo, that you re-wrote history.

另外,正如 Ryan 在评论中所说,一定要让所有人知道可能已经克隆了 repo,你重写了历史。