在 Mercurial 中将已提交的变更集转换为未提交的变更

发布于 2024-12-27 12:28:32 字数 302 浏览 1 评论 0原文

有没有办法将单个提交(例如本地存储库中的提示更改集)转换为工作目录中未提交的更改?
我知道 hg strip 会删除指定的变更集并对其进行备份,但是它是否会将这些变更集转换为工作目录中未提交的更改?

编辑:

关于使用 hg rollback

如果我在执行 hg 回滚 之前有未提交的更改怎么办?我必须先提交这些吗?最后几次提交怎么样?顺序 hg 回滚 是否会将这些提交的更改叠加到现有未提交的更改?

Is there a way to convert a single commit (e.g. tip changeset in my local repository) to uncommitted changes in working directory?
I know that hg strip removes specified changeset(s) and backs it/them up, but does it convert those changesets to uncommited changes in working directory?

EDIT :

Concerning usage of hg rollback.

What if I have uncommitted changes before I want to do hg rollback? Do I have to commit those first? What about last several commits? Does sequential hg rollback stack up changes from those commits to existing uncommitted changes?

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

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

发布评论

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

评论(3

鸩远一方 2025-01-03 12:28:32

如果您尝试重做上次提交(也许使用更好的提交消息,也许修复了错误),那么您现在应该使用

$ hg commit --amend

更新最后一次提交。这比使用 hg rollback 安全得多,如下所述。

如果提交是最后一次提交并且您未在任何地方更新,那么您可以使用hg rollback。请阅读hg help rollback——这是否是一个潜在的破坏性命令。

它的作用:hg rollback将回滚最后一个事务你的存储库。每次您hg commithg pullhg unbundle等时,您都会创建一个新事务。当所有内容都安全存储后,Mercurial 就会关闭事务。如果事务过程中出现问题,Mercurial 可以恢复(请参阅hg receive)。您还可以使用 hg rollback 手动回滚最后一个事务。请参阅 hg rollback --dry-run 以预览该命令将执行的操作。

回滚命令不会影响您的工作副本。这意味着之前显示为已修改的文件将再次显示为已修改。所以很容易做到

$ hg commit -m "Fixed buug-123"

Ups,提交信息中的拼写错误!让我们解决这个问题:(

$ hg rollback
$ hg commit -m "Fixed bug-123"

在 Mercurial 2.2 及更高版本中使用 hg commit --amend 代替。)

最后的提交消息也保存在 .hg/last-message.txt 中,因此如果您的 shell 历史记录中没有它,您可以从那里恢复它。

如果我在执行 hg 回滚之前有未提交的更改怎么办?我必须先提交这些吗?

回滚不会触及工作副本。这意味着工作副本中的任何其他更改都将与更改集中的更改一起显示。就好像您根本没有输入 hg commit 一样。

最近几次提交怎么样?顺序 hg 回滚是否会将这些提交的更改叠加到现有未提交的更改?

不,您只有一级回滚,因为我们只跟踪最后一个事务。

If you're trying to redo the last commit (perhaps with a better commit message, perhaps with a bug fixed) then you should now use

$ hg commit --amend

to update the last commit. That is much safer than using hg rollback as described below.

If the commit is the last commit and you have not updated anywhere, then you can use hg rollback. Please read hg help rollback — is it a potentially destructive command.

What it does: hg rollback will roll back the last transaction in your repository. Every time you hg commit, hg pull, hg unbundle, etc, you create a new transaction. When everything is stored safely, Mercurial closes the transaction. If something goes wrong in the middle of the transaction, Mercurial can recover (see hg recover). You can also manually roll back the last transaction with hg rollback. See hg rollback --dry-run for a preview of what the command will do.

The rollback command wont touch your working copy. This means that files that showed up as modified before will appear modified again. So it's easy to do

$ hg commit -m "Fixed buug-123"

Ups, typo in the commit message! Let's fix that:

$ hg rollback
$ hg commit -m "Fixed bug-123"

(Use hg commit --amend instead with Mercurial 2.2 and later.)

The last commit message is also saved in .hg/last-message.txt so you can recover it from there if you don't have it in your shell history.

What if I have uncommited changes before I want to do hg rollback? Do I have to commit those first?

Rollback doesn't touch the working copy. This means that any additional changes in the working copy will appear together with the changes from the changeset. It's as if you didn't type hg commit at all.

What about last several commits? Does sequential hg rollback stack up changes from those commits to existing uncommited changes?

No, you only have one level of rollback since we only track the last transaction.

习ぎ惯性依靠 2025-01-03 12:28:32

任何更简单的变更集(或一组变更集)都可以使用 Mercurial 队列 转换为本地变更(折叠|展开变更集)

以 TortoiseHG 为中心的手册(适用于旧 GUI)逐步显示操作

Any changeset (or set of changesets) more easy can be converted to local changes with Mercurial Queues (fold|unfold changeset)

TortoiseHG-centric manual (for old GUI) show operations step-by-step

带上头具痛哭 2025-01-03 12:28:32

尽管您可能应该尽可能使用 hg commit --ammend ,但我现在更喜欢新的、更强大的 mecurial 历史编辑功能:hg histedit 特别是如果您熟悉 git。

您只需执行 hg out 即可查看要返回的修订版本(即您想要选择尚未推送的修订版本)。

Although you should probably use hg commit --ammend when possible I now prefer the new and more powerful mecurial history editing feature: hg histedit especially if your familiar with git.

You can see what revision you want to go back by simply doing an hg out (ie you want to pick the revision that has not been pushed).

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