我一直在使用 Mercurial,但想快速演示一下 Git。
什么是 Git 等价物:
hg init . # start a project in the current directory
hg addremove # look for any added or deleted files
hg commit -m "comment" # commit any uncomitted changes
hg status # what have i changed since the last commit?
最佳答案
The Git-HG rosetta stone is not bad
两者之间还有一些其他陷阱没有提到。当我走另一条路 (git -> hg) 时,这个列表是从我自己的博客文章中抄袭的。
Mercurial .hgignore
, 语法:glob 与 git 的 .gitignore 行为相同。
Git .git/config
, ~/.gitconfig
, 使用 git-config 修改值
Mercurial .hg/hgrc
, ~/.hgrc
, 使用 hg help -c config
Git git commit -v<br>
Mercurial hg diff | less; hg commit
Git gitk<br>
Mercurial hg view, or thg from [TortoiseHg][1]
Git git gui<br>
Hg Mercurial 没有提供 GUI 来选择变更集,只有控制台 hg record
命令。
Git git rebase<br>
Mercurial hg rebase .对于 git rebase --interactive
有 hg histedit , 或 Mercurial 队列
Git git push URL ; git remote add origin URL<br>
Mercurial hg push URL; $EDITOR .hg/hgrc ; [paths] default = URL
Git gitk, git log origin/master..HEAD<br>
Mercurial hg outgoing
Git git format-patch RANGE<br>
Mercurial hg email -m filename -o
Git git add . ;
注意点
Mercurial hg add ;
不需 Gist 。
Git git checkout REVISION-KEY<br>
Mercurial hg update CHANGESET
只是为了填补空白,一些来自 Mercurial 的最有用的命令:
Mercurial hg record
Git git add -p; git commit
Hg Mercurial 公司 [URL]
Git 没有真正的等价物。你只能做相当于 hg pull; hg log -r .:
的事情
Mercurial hg out URL
Git 知道的请补充
为了解决 merge 冲突,hg resolve
Mercurial 中的命令有几个选项可以改变行为:
Mercurial hg resolve -m FILE
(将文件标记为已通过手动修复冲突问题得到解决)
Git git add FILE
Mercurial hg resolve -u FILE
将文件标记为未解析
Git git reset HEAD FILE
取消暂存文件
Mercurial hg resolve -l
(列出已解决/未解决冲突的文件)
Git git status
- 干净 merge 的文件自动添加到索引中,那些没有冲突的文件
Mercurial hg resolve FILE
( merge 后,尝试重新 merge 文件)
Git 没有我所知道的重新 merge 的等价物。
关于最常见的 Mercurial 命令的 Git 等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1450348/