I’ve been using Mercurial but would like to do a quick demo of Git.
What are the Git equivalents of:
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
There are a few other gotchas between the two not mentioned there. This list was cribbed from my own blog post when I went the other way (git -> hg).
Hg
.hgignore, syntax: glob is the same behaviour as git’s .gitignore.Git
.git/config,~/.gitconfig, use git-config to modify the valuesHg
.hg/hgrc,~/.hgrc, usehg help -c configGit
git commit -v<br>Hg
hg diff | less; hg commitGit
gitk<br>Hg
hg view, or thg from [TortoiseHg][1]Git
git gui<br>Hg Mercurial doesn’t ship GUI to select changesets, only console
hg recordcommand.Git
git rebase<br>Hg hg rebase. For
git rebase --interactivethere’s hg histedit, or Mercurial QueuesGit
git push URL ; git remote add origin URL<br>Hg
hg push URL; $EDITOR .hg/hgrc ; [paths] default = URLGit
gitk, git log origin/master..HEAD<br>Hg
hg outgoingGit
git format-patch RANGE<br>Hg
hg email -m filename -oGit
git add . ;Note the dotHg
hg add ;No dot needed.Git
git checkout REVISION-KEY<br>Hg
hg update CHANGESETJust to fill the blanks, some of the most useful commands from Mercurial:
Hg
hg recordGit
git add -p; git commitHg hg inc [URL]
Git No real equivalent. You can only do equivalent of
hg pull; hg log -r .:Hg
hg out URLGit Please add if you know how.
For merge conflict resolution, the
hg resolvecommand in Mercurial has a few options that change the behaviour:Hg
hg resolve -m FILE(marks the file as having been resolved by manually fixing up the conflict problem)Git
git add FILEHg
hg resolve -u FILEmarks the file as having been unresolvedGit
git reset HEAD FILEto unstage the fileHg
hg resolve -l(lists files with resolved/unresolved conflicts)Git
git status– files that merged cleanly are added to the index automatically, those that are not have conflictsHg
hg resolve FILE(after a merge, attempts to re-merge the file)Git no equivalent for re-merging that I know of.