[英]Mercurial: How to pull and update to a specific tag
I would like to pull the latest changesets from a remote repository and at the same time, update my local repo to a certain tag
. 我想从远程存储库中提取最新的变更集,同时将我的本地仓库更新为某个tag
。 Something similar as hg fetch
or hg pull -u
, but with an update to a tag. 与hg fetch
或hg pull -u
相似,但具有标签的更新。 In two lines of code, this is: 在两行代码中,这是:
hg pull
hg update mytag
hg pull --help
reveals the following, but unfortunately none of them are working for a tag: hg pull --help
显示以下内容,但不幸的是,这些标签都无法使用:
options:
-u --update update to new branch head if changesets were pulled
-f --force run even when remote repository is unrelated
-r --rev REV [+] a remote changeset intended to be added
-B --bookmark BOOKMARK [+] bookmark to pull
-b --branch BRANCH [+] a specific branch you would like to pull
-e --ssh CMD specify ssh command to use
--remotecmd CMD specify hg command to run on the remote side
--insecure do not verify server certificate (ignoring web.cacerts config)
What I tried: 我试过的
hg pull -r mytag only pulls the latest changesets, but no update
hg pull -u pulls and updates to tip, but no tag allowed
hg pull -b mytag abort: unknown branch
hg pull -B mytag abort: remote bookmark mytag not found
Is it possible to do it in one line? 可以一行完成吗?
With vanilla Mercurial, there is no command to pull & update to a certain tag, revision or whatever. 对于香草Mercurial,没有命令可以将&提取并更新到特定标签,修订版或其他内容。
hg pull
hg update mytag
or 要么
hg pull
hg update -r REVNUMBER
Will do the job just fine, I wouldn't complicate it with aliases and functions that saves me from doing only one extra command. 会做的很好,我不会使用别名和函数使它复杂化,从而使我不必再执行一条额外的命令。
If you are working with command line, this will help you. 如果您使用命令行,这将对您有所帮助。
Making a function first. 首先执行功能。
function pullandup(){ hg pull; hg up $1; }
$1
will be replaced by the first command line argument. $1
将被第一个命令行参数替换。 So this function performs hg pull
first than takes a command line argument and updates
the working directory to specified revision/bookmark/tag. 因此,此函数首先执行hg pull
而不执行命令行参数,然后将工作目录updates
为指定的修订版/书签/标签。
You can create an alias of this and call the function. 您可以为此创建一个别名并调用该函数。
alias pull_up='function pullandup(){ hg pull; hg up $1; };pullandup'
Running 运行
pull_up mytag
will first pull all the latest changesets and will update your working directory to mytag
. 首先将提取所有最新的变更集,并将您的工作目录更新为mytag
。
There may be differences while working with other terminals, this one is for BASH. 与其他终端一起使用时可能会有所不同,该终端用于BASH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.