git 检查 HG 中的变更集
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1312633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Examining a changeset in HG
提问by notnoop
How can I examine a changeset in mercurial without looking up its parent? In mercurial, what's the equivalent of
如何在不查找其父项的情况下检查 mercurial 中的变更集?在 mercurial 中,相当于
git show HEAD^
Git-show gives the changeset metadata and the diff as well.
Git-show 还提供了变更集元数据和差异。
回答by Steve Losh
Your question has two parts. First, how to get the metadata and diff for a changeset all at once:
你的问题有两个部分。首先,如何一次性获取变更集的元数据和差异:
hg log --patch --rev tip
You can shorten the options:
您可以缩短选项:
hg log -pr tip
The second part of the question is how to say "the parent changeset of X" without looking it up. For that you can use the parentrevspec extensionMartin mentioned.
问题的第二部分是如何在不查找的情况下说出“X 的父变更集”。为此,您可以使用Martin 提到的parentrevspec 扩展。
Once you enable the extension you can do:
启用扩展后,您可以执行以下操作:
hg log -pr tip^
You could add an alias to your ~/.hgrc
file if you don't want to retrain your fingers from git's command:
~/.hgrc
如果您不想从 git 的命令中重新训练您的手指,您可以为您的文件添加一个别名:
[alias]
show = log -pr
Then you could use:
然后你可以使用:
hg show tip^
回答by tonfa
I think you want hg export cset
.
我想你想hg export cset
。
回答by Alex
A similar command to "git show HEAD^" would be:
与“git show HEAD^”类似的命令是:
hg log -pr -2 # -1 (last commit), -2 - one before it, etc.
OR
或者
hg exp tip^ # tip^ is similar to -r -2
or for instance if you want to look at the last 3 commits (with diff):
或者例如,如果您想查看最后 3 次提交(使用差异):
hg log -pr -3: # colon means start 3 commits behind and up to tip inclusive
A bit to late with the answer, but still. :)
答案有点晚了,但仍然如此。:)
UPDATE: apparently now HG supports git syntax as well:
更新:显然现在 HG 也支持 git 语法:
hg exp tip^^^..tip
or
或者
hg log -pr tip~4
回答by Amir Memon
If you just want to see the contents and differential of a commit, use this:
如果您只想查看提交的内容和差异,请使用以下命令:
hg diff -c <the commit hash or bookmark name>
To see the commit you've checked out (HEAD in git), do this:
要查看您已签出的提交(git 中的 HEAD),请执行以下操作:
hg diff -c -1
If you want to see the commit before it (HEAD^ in git), do this:
如果你想在它之前查看提交(git 中的 HEAD^),请执行以下操作:
hg diff -c -2
Simple.
简单的。
回答by Martin Geisler
You should also take a look at the parentrevspec extensionto enable a more Git-like syntax for specifying revisions.
您还应该查看parentrevspec 扩展,以启用更类似于 Git 的语法来指定修订。