User:RokerHRO/hg2git Rosetta Stone

From Wikipedia, the free encyclopedia

This is my own hg-2-git "Rosetta Stone" (inspired by https://github.com/sympy/sympy/wiki/Git-hg-rosetta-stone#Rosetta_Stone but with commands & config items relevant for me and my work.


Setup & initialization[edit]

Task in Mercurial in Git
using "kdiff3" as default merge tool used to solve conflicts in ~/.hgrc or project's .hg/hgrc:
[extdiff]
cmd.kdiff3 =

[merge-tools]
kdiff3.args = $base $local $other -o $output
// TODO -> https://www.vhinandrich.com/blog/guide-configure-kdiff3-git-merge-tool-and-diff-tool-mac

Daily work[edit]

What I want to do Mercurial Git
Create a new branch hg branch branchname

hg commit -m "create branch …"
hg push --new-branch

// TODO

git checkout -b branchname
git commit -m "Commit content"
git push -u origin branchname

Look locally on the revision graph in the web browser hg serve -p 9999 …???

Emergency[edit]

What I need to do Mercurial Git
Strip the last (unpushed) commit hg strip -r -1 --keep // TODO git reset --soft HEAD~1
undo a (maybe older and already pushed) commit (by applying a "reverse diff" that effectively undoes its changes hg backout commid_id git revert commit_id
backout a merge commit // There are several pages on the Web explainin this step-by-step. In fact I have to create 2 different backouts and some merges afertwards. // No clue: https://www.datree.io/resources/git-undo-merge --> git revert -m # commit_id if you do -m 1 you take the branch before merge (base), if you take -m 2 you take the merged branch in, this makes sense on git as branches can be deleted on remote.