$30 off During Our Annual Pro Sale. View Details »

Mercurial on GitHub

Mercurial on GitHub

An internal presentation on using Mercurial on GitHub.

Klemen Slavič

October 05, 2011
Tweet

More Decks by Klemen Slavič

Other Decks in Programming

Transcript

  1. Mercurial on
    GitHub
    A crash course introduction

    View Slide

  2. Subversion vs. Mercurial
    • Distributed repositories
    • Branches are basically
    clones inside the same
    repository
    • Non-linear history
    • Revision numbers are
    local
    • Commits are offline
    • Moving and renaming
    is tracked
    • Central repository
    • Branches are copies
    inside same directory
    structure
    • Global linear history
    • Revisions numbers are
    sequential and global
    • Commits are online
    • Moving and renaming
    is a combination of
    delete/add

    View Slide

  3. Subversion workflow
    • Check out working copy
    o
    • Make changes
    o ...
    o
    • Commit changes
    o "
    • Update copy
    o

    View Slide

  4. Mercurial workflow
    • Clone a repository
    o
    • Work, slave!
    o ...
    o " "
    • Pull changes
    o
    o (if pull creates multiple heads)
    • Push changes
    o

    View Slide

  5. Mercurial
    • Commits are always local
    • You can push multiple commits at a time
    • Mercurial blocks a push where it would create
    multiple heads in the remote
    o In this case, pull changes, update, merge, commit and push

    View Slide

  6. Working with repositories
    organization/repo
    user1/repo user2/repo user3/repo
    user1-local/repo
    pull
    request
    pull/push
    pull pull
    pull

    View Slide

  7. History in Mercurial
    head/
    tip

    View Slide

  8. History in Mercurial
    head/
    tip
    head

    View Slide

  9. History in Mercurial

    head/
    tip

    View Slide

  10. Branches in Mercurial
    • Repositories can be treated as branches
    • When pulling, changes commited are added as a
    nameless branch
    • You can switch to a branch by using
    • Merging and commiting preserves current branch
    • To push a non-existant branch to remote, use

    View Slide

  11. Pushing changes
    • Always pull and update before pushing
    o –
    o hg merge (if two heads are created)
    o
    o
    • Don‘t push to main repository directly!
    Use Pull Requests.

    View Slide

  12. Sharing changes offline
    • You can run a local repository server to share
    changes offline (via )
    o
    • Enables users to pull changes, but cannot push

    View Slide

  13. Setting up your
    environment
    • Create SSH key for GitHub:
    o
    o – –
    • create key named
    o
    • Copy the key to GitHub
    • Set up SSH key mapping
    o

    View Slide

  14. Set up Mercurial



    o

    • Fork the base repository!

    View Slide

  15. Check out source



    o

    View Slide

  16. Incoming and outgoing
    changes
    • To preview the incoming changes without pulling:
    o
    • To preview outgoing changes without pushing:
    o

    View Slide

  17. Working with GitHub
    • Pull changes from base repository and update
    o
    • Create local changes
    o
    • Commit
    o
    • Verify outgoing changes and push
    o
    o
    • If you‘re ready to push to base repository, create a pull
    request

    View Slide

  18. That‘s about it.
    • Go hack.

    View Slide