Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git and Hg

Git and Hg

A comparison of commands and concepts in git and hg

David Newell

March 22, 2013
Tweet

More Decks by David Newell

Other Decks in Programming

Transcript

  1. BitKeeper and BitMover Troubles Git - April 3rd, 2005 -

    April 18th, 2005: First Merge - Linus Torvald Hg - April 19th, 2005 - Matt Mackall History
  2. Git - Snapshots Hg - Changesets Git and Hg -

    mix of both for compression Tracking Changes
  3. Git cherry-pick - diff 2 files - apply changeset Hg

    graft - apply changes to previous snapshots - for source and destination - apply changeset Cherry-picking and Grafting
  4. Pulling changes git pull git fetch hg pull -u git

    merge hg merge git commit git commit hg commit
  5. Committing git add <file> hg pull -u git commit git

    commit -a hg commit git pull git pull git push git push hg push
  6. git stash git merge git stash pop Can add multiple

    commits to stash hg shelve extension I don't want to commit everything
  7. Shortcuts: Git and Hg <rev>^ (^<rev> is different) <rev>^ <rev1>..<rev2>

    <rev2> - <rev1> (not <rev1>.. <rev2>) :/<some text> desc(<some text>) <ref>@{<a time>} date(<interval>)
  8. git branch === hg bookmark hg branch !== git anything

    hg has multiple heads - anonymous branches git detaches the head - must reattach to commit Branching
  9. Both local Can be pushed remotely Can be pulled remotely

    Can be named differently Really, your clone is on a local branch Git: Clone ~= Branch
  10. git rebase staging git rebase --onto production staging <feature> git

    merge staging git merge --abort git add git commit Merging a Git branch
  11. hg merge staging hg update -C -r HEAD^ hg resolve

    hg commit Rebase with extension Merging an Hg branch
  12. Hg - checkout previous version - commit correction as new

    head Git - checkout previous version - rewrite history to include correction I made a mistake
  13. Hg - complete history - every merge logged Git -

    clean history - linear history History