在 Mercurial 中将已提交的变更集转换为未提交的变更
有没有办法将单个提交(例如本地存储库中的提示更改集)转换为工作目录中未提交的更改?
我知道 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果提交是最后一次提交并且您未在任何地方更新,那么您可以使用
hg rollback
。请阅读hg help rollback
——这是否是一个潜在的破坏性命令。它的作用:
hg rollback
将回滚最后一个事务你的存储库。每次您hg commit
、hg pull
、hg unbundle
等时,您都会创建一个新事务。当所有内容都安全存储后,Mercurial 就会关闭事务。如果事务过程中出现问题,Mercurial 可以恢复(请参阅hg receive
)。您还可以使用hg rollback
手动回滚最后一个事务。请参阅hg rollback --dry-run
以预览该命令将执行的操作。回滚命令不会影响您的工作副本。这意味着之前显示为已修改的文件将再次显示为已修改。所以很容易做到
Ups,提交信息中的拼写错误!让我们解决这个问题:(
在 Mercurial 2.2 及更高版本中使用
hg commit --amend
代替。)最后的提交消息也保存在
.hg/last-message.txt
中,因此如果您的 shell 历史记录中没有它,您可以从那里恢复它。回滚不会触及工作副本。这意味着工作副本中的任何其他更改都将与更改集中的更改一起显示。就好像您根本没有输入 hg commit 一样。
不,您只有一级回滚,因为我们只跟踪最后一个事务。
If the commit is the last commit and you have not updated anywhere, then you can use
hg rollback
. Please readhg help rollback
— is it a potentially destructive command.What it does:
hg rollback
will roll back the last transaction in your repository. Every time youhg 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 (seehg recover
). You can also manually roll back the last transaction withhg rollback
. Seehg 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
Ups, typo in the commit message! Let's fix that:
(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.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.
No, you only have one level of rollback since we only track the last transaction.
任何更简单的变更集(或一组变更集)都可以使用 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
尽管您可能应该尽可能使用 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).