在 Mercurial 中提交和回滚后恢复丢失的文件。 (相当于 git reflog?)

发布于 2024-12-03 17:41:15 字数 2049 浏览 0 评论 0原文

致力于工作。当我不在回购协议的顶端时进行了回滚。文件丢失。寻找 git reflog 相当于保存我的工作。

长的: 所以我完成工作,然后提交。

$ hg commit -A
[...]
adding media/js/fbfriends.js
removing media/js/streams.js
adding media/js/templetizer.js
[...]
$ hg log
$ hg log
changeset:   10:ce3ad416d9a5
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:34:35 2011 -0700
summary:     Save all.

changeset:   9:ceacb7b2192a
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.
[...]

一些浏览:

$ hg checkout 8

好的。然后我想更改修订版 10。愚蠢的是,我这样做了:

$ hg rollback
rolling back to revision 9 (undo commit)
$ hg status
[...]
M media/js/mootools.js
R media/js/streams.js
! media/js/fbfriends.js
! media/js/templetizer.js
[...]

WTF?我的两个文件去哪了???

$ hg log
changeset:   9:ceacb7b2192a
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.
[...]

好的,我会找出 .orig 文件:

$ hg revert --all
[...]
undeleting media/js/streams.js
forgetting media/js/templetizer.js
reverting media/js/mootools.js
[...] // media/js/fbfriends.js doesn't even show up
$ hg status
? media/js/mootools.js.orig
$ hg history
changeset:   9:ceacb7b2192a
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.

NOOOOOOO!当我进行回滚时,我因处于提交 8 状态而受到了极大的批评。 恢复尝试失败:

$ hg checkout 10
8 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find -name temp
$ hg checkout 9
30 files updated, 0 files merged, 63 files removed, 0 files unresolved
$ find -name temp
$ hg checkout ce3ad416d9a5
abort: unknown revision 'ce3ad416d9a5'!
$ hg checkout ceacb7b2192a
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find -name temp
$

但是,但是..我把它推了进去!它应该仍然在 .hg 中的某个地方吗?帮助? git refloggit checkout blah 在几次实例中救了我,但是有没有任何水银等价物?

编辑:使摘要清晰。 EDIT2:更好的标题。

Commited work. Did a rollback when I wasn't on the tip of the repo. Lost files. Looking for git reflog equivalent to save my work.

Long:
So I finish work, then commit.

$ hg commit -A
[...]
adding media/js/fbfriends.js
removing media/js/streams.js
adding media/js/templetizer.js
[...]
$ hg log
$ hg log
changeset:   10:ce3ad416d9a5
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:34:35 2011 -0700
summary:     Save all.

changeset:   9:ceacb7b2192a
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.
[...]

Some browsing:

$ hg checkout 8

Okay. Then I wanted to change revision 10. Stupidly, I do:

$ hg rollback
rolling back to revision 9 (undo commit)
$ hg status
[...]
M media/js/mootools.js
R media/js/streams.js
! media/js/fbfriends.js
! media/js/templetizer.js
[...]

WTF? Where did my two files go????

$ hg log
changeset:   9:ceacb7b2192a
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.
[...]

Okay, i'll figure out the .orig files:

$ hg revert --all
[...]
undeleting media/js/streams.js
forgetting media/js/templetizer.js
reverting media/js/mootools.js
[...] // media/js/fbfriends.js doesn't even show up
$ hg status
? media/js/mootools.js.orig
$ hg history
changeset:   9:ceacb7b2192a
tag:         tip
user:        Mihai
date:        Sat Sep 10 22:25:34 2011 -0700
summary:     Mootools update.

NOOOOOO! I've been royally fscked for being on commit 8 when i did the rollback.
Recovery attempts fail:

$ hg checkout 10
8 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find -name temp
$ hg checkout 9
30 files updated, 0 files merged, 63 files removed, 0 files unresolved
$ find -name temp
$ hg checkout ce3ad416d9a5
abort: unknown revision 'ce3ad416d9a5'!
$ hg checkout ceacb7b2192a
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ find -name temp
$

But, but.. I pushed it in! It should still be somewhere in .hg? Help?
git reflog, git checkout blah saved me in a couple instances but are there any mercurial equivalents?

EDIT: Made summary clear.
EDIT2: Better title.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

π浅易 2024-12-10 17:41:15

抱歉,他们走了。

rollback 命令的帮助摘要是:

roll back the last transaction (dangerous)

并继续说道:

This command should be used with care. There is only one level of
rollback, and there is no way to undo a rollback. It will also restore the
dirstate at the time of the last transaction, losing any dirstate changes
since that time. This command does not alter the working directory.

Rollback 是删除历史记录的唯一非扩展 Mercurial 命令,并且有人讨论将其移动到一个默认禁用的扩展,就像它具有类似破坏性的表兄弟 strippurge 一样。

并不是说它现在对您有帮助,而是在将来进行回滚之前进行克隆。或者更好的是执行backout。取消添加了更改的逆操作,产生相同的结果提示修订,但具有更准确的历史记录(“我做了这个”,“我撤消了它”)。

Sorry, they are gone.

The help summary for the rollback command is:

roll back the last transaction (dangerous)

and goes on to say:

This command should be used with care. There is only one level of
rollback, and there is no way to undo a rollback. It will also restore the
dirstate at the time of the last transaction, losing any dirstate changes
since that time. This command does not alter the working directory.

Rollback is the only non-extension mercurial command that removes history, and there's been talk about moving it to a disabled-by-default extension like it's similarly destructive cousins strip and purge.

Not that it helps you now, but in the future clone before doing a rollback. Or better yet do a backout instead. Backout adds the inverse of a change, yielding the same resulting tip revision, but with a more accurate history ("I did this", "I undid it").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文