如何从历史记录中永久删除(删除)文件?
我提交(未推送)本地许多文件(包括删除和添加二进制文件...),现在当我尝试推起来需要很多时间。实际上我搞乱了我的本地回购历史。
以后我怎样才能避免这个错误呢?我可以将一组本地修订版 1->2->3->4 转换为 1->2,其中 2 是本地修订版的最终修订版克隆 ?
编辑:因为我很着急,所以我从头开始使用修订版 4 开始了一个新的远程存储库。将来我将使用标记的答案,因为它看起来更容易,但我会挖掘其他解决方案来了解真相。感谢您的支持。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您的问题中尚不清楚这些更改是否已被推动。如果它们仍然是本地的,您或多或少可以轻松地摆脱它们。 转换是一种选择。您还可以使用MQ(水银队列)。请查看 EditingHistory wiki 文章以获取详细说明。它建议 MQ 是最简单的方法。
为了防止此类错误,您可能应该添加一个钩子来拒绝“坏”提交,因为您可以通过编程方式描述它们;)
It's not clear from your question whether those changes got pushed. If they're still local, you can more or less get rid of them easily. convert is one option. You can also use MQ (mercurial queues). Check the EditingHistory wiki article for a detailed explanation. It recommends MQ being the simplest approach.
To prevent that kind of mistakes, you should probably add a hook to reject 'bad' commits, given that you can describe them programatically ;)
Mercurial 历史记录是不可变的,您无法使用普通工具删除。但是,您可以创建一个没有这些文件的新存储库:
仅从旧存储库中获取修订版 0 和 1,并将它们放入新存储库中。现在将修订版四中的文件复制到新的存储库中并提交。
这消除了那些间质性变更集,但是您在野外拥有的任何存储库仍然拥有它们,因此当您
拉动
时,您将把它们找回来。一般来说,一旦你推送了一个变更集,它就在那里,除非你能让每个拥有克隆的人删除它并重新克隆,否则你就不走运了。
Mercurial history is immutable, you can't delete using the normal tools. You can, however, create a new repo without those files:
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.