Git清除远程存储库 [英] Git clear remote repository

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

问题描述

如果我将一个错误的初始提交(或多个)提交到远程存储库并且想要清除它/销毁它 - 我可以通过命令执行它吗?



将它完全从服务器上删除非常重要,所以它不会占用磁盘空间。



EG今天,我推出了一个完整的Visual Studio项目,包括dll,sdfs等等。首先这个文件是相当大的,其次它们中的一些被其他开发者的VS修改,并且不能被合并。这使我谷歌一点点,我发现这些文件应该被忽略。但第一次提交已经混乱了我的存储库。我想删除这个并释放磁盘空间。

可以通过主机的网站(assembla)删除git repo并重新添加它,但这听起来不像我的解决方案..是否有更专业的方式?






更新:



下面但它不起作用:
'git push -f''git push --force''git push origin -f''git push origin --force'
导致:

  $ git push --force 
计数对象:19,完成。
使用多达4个线程的增量压缩。
压缩对象:100%(19/19),完成。
写作对象:100%(19/19),6.85 KiB,完成。
合计19(delta 3),重用0(delta 0)
remote:错误:拒绝非快进refs / heads / master(您应该扣除

至git@git.assembla.com:xxxxx.git
! [remote rejected] master - >主(非快进)
错误:无法将某些参考推送到'git@git.assembla.com:xxxxx.git'


解决方案

您可以用 git push -f 强制推送正确的回购。根据主机,当 git gc 运行时,松散对象将被清除。 update:根据,您无法在组合中强制 git gc



如果你想让它们立即清理干净, t允许你强制 git gc ,另一种选择是删除repo并推送一个新的。



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


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.

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?


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 --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 git@git.assembla.com:xxxxx.git
 ! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@git.assembla.com:xxxxx.git'

解决方案

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

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.

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.

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

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