Git vs Mercurial
Jump to navigation
Jump to search
Git vs Mercurial Table
Git | Mercurial |
---|---|
git pull | hg pull -u |
git fetch | hg pull |
git reset --hard | hg update -C |
git revert <commit> | hg backout <cset> |
git add <new_file> | hg add <new_file> (Only equivalent when <new_file> is not tracked.) |
git add <file> | Not necessary in Mercurial. |
git reset | Not necessary in Mercurial. |
git add -i | hg record |
git commit -a | hg commit |
git commit --amend | hg commit --amend |
git blame | hg blame or hg annotate |
git blame -C | (closest equivalent): hg grep --all |
git bisect | hg bisect |
git rebase --interactive | hg histedit <base cset> (Requires the HisteditExtension.) |
git stash | hg shelve (Requires the ShelveExtension or the AtticExtension.) |
git merge | hg merge |
git cherry-pick <commit> | hg graft <cset> |
git rebase <upstream> | hg rebase -d <cset> (Requires the RebaseExtension.) |
git format-patch <commits> and git send-mail | hg email -r <csets> (Requires the PatchbombExtension.) |
git am <mbox> | hg mimport -m <mbox> (Requires the MboxExtension and the MqExtension. Imports patches to mq.) |
git checkout HEAD | hg update |
git log -n | hg log --limit n |
git push | hg push |
Source: Git vs Mercurial - WikiVS - http://www.wikivs.com/wiki/Git_vs_Mercurial
Command equivalence table
Git command | Hg command | Notes |
---|---|---|
git pull | hg fetch hg pull -u |
The fetch command is more similar but requires the <a href="/wiki/FetchExtension">FetchExtension</a> to be enabled. |
git fetch | hg pull | |
git push | hg push -r . | By default, git only pushes the current branch. |
git checkout <commit> | hg update -c <cset> | git checks and reloads (accidentally) removed files |
git checkout [<rev>] -- <file(s)> | hg revert [-r <rev>] <file(s)> | |
git reset --hard | hg revert -a --no-backup | |
git reset --hard HEAD~1 | hg strip -r . | |
git revert <commit> | hg backout <cset> | |
git add <new_file> | hg add <new_file> | Only equivalent when <new_file> is not tracked. |
git add <file> git reset HEAD <file> |
— | Not necessary in Mercurial (see shelve below for partial commit support). |
git add -i | hg record | Requires the <a href="/wiki/RecordExtension">RecordExtension</a> to be enabled. |
git commit --amend | hg commit --amend | |
git rebase --interactive | hg histedit <base cset> | Requires the <a href="/wiki/HisteditExtension">HisteditExtension</a>. In core since version 2.3 |
git stash | hg shelve | Requires the <a href="/wiki/ShelveExtension">ShelveExtension</a> or the <a href="/wiki/AtticExtension">AtticExtension</a>. |
git merge | hg merge | git merge is capable of octopus merges, while mercurial merge prefers multiple merges |
git cherry-pick <commit> | hg transplant <cset> hg graft <csets> |
Transplant requires the <a href="/wiki/TransplantExtension">TransplantExtension</a>. Graft is available in 2.0 and higher. |
git rebase <upstream> | hg rebase -d <cset> | Requires the <a href="/wiki/RebaseExtension">RebaseExtension</a>. |
git format-patch <commits> and git send-mail | hg email -r <csets> | Requires the <a href="/wiki/PatchbombExtension">PatchbombExtension</a>. |
git am <mbox> | hg mimport -m <mbox> | Requires the <a href="/wiki/MboxExtension">MboxExtension</a> and the <a href="/wiki/MqExtension">MqExtension</a>. Imports patches to mq. |
git describe | hg log -r . --template '{latesttag}-{latesttagdistance}-{node|short}\n' | |
git describe rev | hg log -r rev --template '{latesttag}-{latesttagdistance}-{node|short}\n' | |
git log origin..HEAD git log origin/foobranch..HEAD |
hg outgoing | |
git fetch && git log HEAD..origin | hg incoming | git fetch keeps the changesets while hg incoming (without --bundle foo) discards them. Use git pull (will fetch further changes) or git merge origin to update the working directory |
git show rev | hg export rev | |
git show hash:file | hg cat -r rev file | |
git ls-files | hg manifest | |
git log | hg log | |
git log -n | hg log --limit n | |
git ?? | hg summary | |
git status | hg outgoing hg status |
|
git remote add -f remotename url | — | Edit .hg/hgrc and add the line 'remotename = url' under section '[paths]'; see below for getting changesets |
git remote update remotename | hg pull remotename | When remotename is omitted in Git, all remotes are updated. In Mercurial, the default remote is refreshed. |
git branch -a | hg branches | |
git config --global user.(name|email) ... | — | Edit ~/.hgrc section "[ui]", key "username", value "First Last < <a class="mailto" href="mailto:mail@example.org">mail@example.org</a> >" |
git clean or git status --porcelain|sed -r 's:\?\?\s(.*):\1:g'|xargs rm |
hg purge or hg status -un|xargs rm |
purge requires the <a href="/wiki/PurgeExtension">PurgeExtension</a> In Windows you might need to add sed 's:\\:/:g' before piping xargs rm, otherwise the inverted slash in Windows paths will be interpreted as an escape |
Source: GitConcepts - Mercurial - http://mercurial.selenic.com/wiki/GitConcepts#Command_equivalence_table