如何删除像VSTS这样的远程git存储库中的悬空提交 [英] How to remove dangling commits in remote git repository like VSTS

查看:88
本文介绍了如何删除像VSTS这样的远程git存储库中的悬空提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试通过将一些文件移动到git LFS来减小Git存储库的大小.再有几百个命令,这是git LFS中的文件,在我的git commit中不再包含这些文件的历史记录.

I've been trying to decrease the size of my Git repository by moving some files to git LFS. A few 100 commands further, here we are with files in git LFS and no more history of these files in my git commits.

但是,每当克隆存储库时,我仍会下载约3gb的对象.我通过在Visual Studio Team Services中创建一个新的存储库来解决此问题,然后在本地对存储库进行修剪和垃圾回收,然后将其推送到该存储库中,该存储库已减小到300mb. (在本文中本地找到的执行此操作的命令:

However, whenever I clone the repository I am still downloading about 3gb of objects. I worked around this issue by creating a new repository in Visual Studio Team Services and after pruning and garbage collecting my repository locally, then doing a push to there, it was reduced to 300mb. (Command to do this locally found in this post: Git: what is a dangling commit/blob and where do they come from?)

但是我无法想象您总是必须删除/重新创建一个完整的存储库才能删除悬空的提交.

However I can't imagine that you always have to delete / recreate a complete repository to remove dangling commits.

我还尝试过执行git init,然后将其推送到现有存储库中,但这只会进一步增加对象数.

What I also tried was doing a git init, and then pushing that over the existing repository, but it only increased the object count further.

对于同样遇到类似问题的任何人,这些都是我执行的创建新存储库而无需悬而未决提交的命令,但是我想了解如何在现有存储库中执行此操作而不必删除它:

For anyone also running into similar issues, these were the command I executed to create a new repository without dangling commits, I would however like to find out how to do this in the existing repository without having to delete it:

git clone https://avavedse.visualstudio.com/Test/_git/TestRepository
cd blahblah
git reflog expire --expire=now --all
git gc --prune=now
git remote add newrepo https://avavedse.visualstudio.com/Test/_git/TestRepositoryNewEdition
git push newrepo

推荐答案

这可能是 GitHub将定期垃圾收集无法从顶级引用访问的对象.因此,随着时间的流逝,它们会消失.但这不能保证.这是我在此找到的最好的信息.

GitHub will periodically garbage collect objects that cannot be reached from a top-level reference. So over time, they'll disappear. But this is not guaranteed. That's the best info I've found on this.

您可以手动将reflog的到期日期现在更正,然后运行垃圾收集器:

You can manually correct reflogs expiry date to now and run garbage collector:

git reflog expire --expire=now --all
git gc --prune=now

但这只会影响本地存储库.

But this will only affect the local repo.

很明显,垃圾收集器远非理想,因为除非您不介意删除和创建新的回购协议并丢失所有问题,拉取请求等,否则您必须联系

Apparently, the garbage collector is far from being ideal, insomuch that unless you don't mind deleting and creating a new repo and losing all issues, pull requests, etc., you have to contact Github Support :

您可以永久删除缓存的视图和对 通过联系GitHub支持在GitHub上的请求中获取敏感数据 或GitHub高级支持. [docs.github.com]

you can permanently remove cached views and references to the sensitive data in pull requests on GitHub by contacting GitHub Support or GitHub Premium Support.[docs.github.com]

这篇关于如何删除像VSTS这样的远程git存储库中的悬空提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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