当前位置: 首页 > 工具软件 > Mercurial > 使用案例 >

Mercurial常用命令

寿飞飙
2023-12-01

Mercurial常用命令

切换分支

$ hg pull -r thebranch
$ hg update -r thebranch
update 到指定分支: hg update -r branch_name(指定revision) hg update -C branch_name (不指定revision)

清理本地操作

hg purge --all
hg update --clean
清理工作区,并更新到分支的最新revision id
Hg merge --abort
Hg up -Cr 在更新时做深度清理

Build过程

perl build.pl --prepare
perl build.pl --target=WindowsEditor
jam WinEditor

Update到另一分支不成功,需加- -clean

hg update -r 2019.2/china_unity/staging - -clean

关于merge

Pull 全球版和中国版

切换revision

hg update –r revision

跑abv test

run o k

下载

$ hg clone --uncompressed -U https://ono.unity3d.com/unity/trunk unity

查看revision信息

Hg log -r sfjlsaj24802

常用命令

1.hg help (command)
Get help for Mercurial commands, e.g. “hg help update”
2.hg tags
See list of available tags, e.g. “4.5.2f1”, “4.5.3b2”
3.hg pull
Pull latest changes from server to local repository clone
4.hg update
Update local repository to specific revisions/tag, e.g. “hg update -r 4.5.2f1”. This will also download largefiles for this revision
5.hg diff
Show changes locally, or compare to another revision. E.g. “hg diff -r 4.5.2f1 Configuration/BuildConfig.pm” to compare local revision of file with 4.5.2 revision
6.hg status
See if you have any local changes
7.hg purge --all
Delete all local non-tracked files in repository, e.g. builds folder
8.hg id
Shows current revision/tag of local source code
9.hg clone
Clones (“downloads”) repository from server to local machine
10.hg archive
“Copy” files from clone to another folder, without the Mercurial-specific files, useful when e.g. copying files to another version control system. E.g. “hg archive -r 4.5.3f3 D:\OtherRepo”

log用法

hg log -b .
当前branch下的所有log
Hg log --follow
工作目录的变更集
Hg log -l 5
看最新的5条
Hg log -l 5 -b .
当前分支下最新的5条
Hg log -r tip
Tip changelog
Hg status -m
只展示改变了的文件
Hg status -r
只展示移除了的文件
Hg status -a
只展示增加的文件

Mercurial命令和git命令的比较

1.hg update -Cr = git reset –hard
2. hg backout 32jljk4j2 = git revert tag/hash
3. hg graft --edit 0000 = git cherry-pick <commit>
4. hg shelve = git stash

关闭branch时的commit

hg commit --close-branch -m 'closing this branch'

撤销add,commit

有时候我们用hg add 没加参数,直接把所以没有纳入版本库的文件都添加进来了。
而有些文件我们不是想添加的,怎么办?

hg forget xxx.java

撤销commit

hg rollback

hg commit -m “this time is all right.”

如何开启一个新的head,并关闭旧的head

Up到出错前的revision,重新进行新的操作,并push --force,这样会开启一个新head.
然后up到旧的head, hg commit --close-branch -m “…” ,hg push

依据一个分支创建新分支,并push上去

$ hg update -r trunk
$ hg branch platform/webgl/bugfixes
$ hg commit -m “Open platform/webgl/bugfixes branch”
$ hg push --new-branch

 类似资料: