如何从历史记录中永久删除(删除)文件? [英] How do I permanently remove (obliterate) files from history?

查看:101
本文介绍了如何从历史记录中永久删除(删除)文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

承诺 (未推送) ,现在本地有很多文件(包括删除和添加二进制文件...)我尝试推动它需要很多时间.实际上,我搞砸了本地回购记录.

将来如何避免这种错误?我可以将一组本地修订版本 1-> 2-> 3-> 4 转换为 1-> 2 ,其中2是本地克隆的最终版本吗?

edit:因为我很着急,所以我从零开始以修订版4开始了一个新的远程回购.将来,我将使用标记的答案,因为这似乎更容易,但是我将挖掘其他解决方案以了解事实.感谢您的支持.

解决方案

商品历史是一成不变的,您无法使用常规工具删除.但是,您可以创建没有这些文件的新存储库:

$ hg clone -r 1 repo-with-too-much new-repo

只接受旧仓库中的修订版零和修订版,然后将它们放入新仓库中.现在,将版本4中的文件复制到新的仓库中并提交.

这消除了这些插页式变更集,但是您在野外找到的任何回购仍然具有它们,因此,当您pull时,您将把它们取回.

通常,一旦您将变更集推入其中,除非您可以让所有人都拥有一个克隆来删除它并重新克隆,否则您就走运了.

I commited (not pushed) a lot of files locally (including binary files removing & adding...) and now when I try to push it takes a lot of time. Actually I messed up my local repo history.

How could I avoid this mistake in the future ? Can I transform a set of local revision 1->2->3->4 to 1->2 with 2 being the final revision of the local clone ?

edit: since I was in hurry I started a new remote repo from scratch with revision 4. In the future I will go with the marked answer as it seems easier but I will dig other solutions to see the truth. Thx for your support.

解决方案

Mercurial history is immutable, you can't delete using the normal tools. You can, however, create a new repo without those files:

$ hg clone -r 1 repo-with-too-much new-repo

that takes only revisions zero and one from the old repo and puts them into a new repo. Now copy the files from revision four into the new repo and commit.

This gets rid of those interstitial changesets, but any repo you have out there in the wild still has them, so when you pull you'll get them back.

In general once you've pushed a changeset it's out there and unless you can get everyone with a clone to delete it and reclone you're out of luck.

这篇关于如何从历史记录中永久删除(删除)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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