意外地在Mercurial中提交了大量原始数据,如何防止其过载我的Bitbucket存储库? [英] Accidentally committed a large amount of raw data in Mercurial, how do I keep it from overloading my bitbucket repository?

查看:52
本文介绍了意外地在Mercurial中提交了大量原始数据,如何防止其过载我的Bitbucket存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将大量数据从实验室文件服务器复制到笔记本电脑,然后不小心将其提交到了我用来备份论文的Mercurial存储库.

I copied a large amount of data from my labs file server to my laptop, then accidentally committed it to the Mercurial repository I'm using to back up my thesis.

现在,即使删除了文件,我也有200+ MB的数据,不需要占用硬盘空间.这并不是真正的问题,但是我同步到的bitbucket存储库仅给我1 GB的空间,我将需要这些空间来存储我的数据.

Now I have 200+ MB of data I don't need taking up space on my hard disk, even after I've deleted the files. This isn't really a problem, but the bitbucket repository I sync to only gives me 1 GB of space, which I will need for my data.

然后我愚蠢地删除了文件并再次提交,所以我不能只使用 https://stackoverflow中所述的回滚. com/a/3290523/961959 ,而无需创建新的存储库,也无需使用bitbucket重置所有内容.

Stupidly I then deleted the files and committed again, so I can't just use rollback as described in https://stackoverflow.com/a/3290523/961959 without creating a new repository and having to reset up everything with bitbucket.

有没有一种方法可以解决此问题,所以我不会浪费我的存储库空间的四分之一?我可以回滚我最近进行的2次提交吗?

Is there a way I can fix this, so I don't waste a quarter of my repository space? Can I rollback the last 2 commits I did?

推荐答案

我将描述如果我想回滚两个最近的提交将要做什么.

I'm going to describe what I would do if I wanted to roll back two most recent commits.

我认为您尚未推送到Bitbucked.我还假设您在DAG上有这些变更集:

I assume that you haven't pushed to Bitbucked yet. I also assume you have these changesets on top of your DAG:

o  C: Deleted files FILE1 and FILE2
|
o  B: Some nice changes; also added large files FILE1 and FILE2
|
o  A: Some good changeset

在这里,应完全删除C,应编辑B(应回滚FILE1FILE2添加的内容),并保留A及以下版本.

Here, C should be removed altogether, B should be edited (FILE1 and FILE2 additions should be rolled back), and A and below should be left as they are.

注意事项:仅当BC尚未推送到Bitbucked(或任何其他公共仓库)上时,此选项才有效.

Caveat: this only works if B and C were not pushed onto Bitbucked (or any other public repo) yet.

您需要启用MQ扩展才能执行此操作.为此,请将以下行添加到您的仓库中的.hg/hgrc文件中:

You'll need to enable the MQ extension to do this. To do this, add these lines to the .hg/hgrc file in your repo:

[extensions]
mq=

步骤

首先,我剥离C:

$ hg strip C

现在,C被删除,父级为B.我将B导入为Mercurial队列 patch 进行

Now, C is obliterated, and the parent is B. I import B as a Mercurial Queues patch to edit it:

$ hg qimport -r B -n B.patch

现在,我的队列上有一个补丁程序,该补丁程序是从B创建的.我删除了大文件,并刷新了补丁程序:

Now I have one patch on top our queue, which was created from B. I remove the big files, and refresh the patch:

$ hg forget FILE1 FILE2 
$ hg qrefresh

现在B.patch不再包含大文件.但是,它们仍在磁盘上,即使不控制bu Mercurial.现在,我完成了MQ的工作:

Now B.patch no longer includes the big files. However, they are still on the disk, albeit not controlled bu Mercurial. I now finish my work with MQ:

$ hg qfinish -a

这是我现在拥有的:

o  B1: Some nice changes, no big files here
|
o  A: Some good changeset

这篇关于意外地在Mercurial中提交了大量原始数据,如何防止其过载我的Bitbucket存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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