Using Mercurial (Hg), TortoiseHg, and BitBucket

http://bitbucket.org/ (Use an academic email address)
https://www.atlassian.com/software/views/bitbucket-academic-license.jsp

http://tortoisehg.bitbucket.org/

The Point-and-Click way of doing things:

Definitions:
* DVCS = Distributed Version Control System. Mercurial (Hg) and Git are examples of DVCSs. They’re Version Control Systems because they track all changes made to your code. They’re Distributed because anyone who has a copy of your respository (see below) has a full backup of the entire repository (and all of the history that it contains).
* Repository (“Repo”) = A Mercurial-tracked folder of files.
* Commit = (Used as a noun) A point in time that you’ve marked in your repo The repo can roll back to any commit. Once a commit has been made, it cannot (with few exceptions) be deleted from the repo.
* Push = Sending your files up to a server (for example, BitBucket).
* Pull = Accepting changes to your repo from someone or from a central server.

Steps for any new project:

1) In TortoiseHg, create a New Repository. You may need to set your Name in the settings menu.
(Right click on the repository (left menu), and open the Settings menu. Under “Commit” -> Username, type your name and email address)

2) Do an initial commit to add your files into the repo To add them, look for a bunch of files with ‘?’ next to them — this means that Mercurial doesn’t know about these files. Put a check mark next to them to add them, and Commit them to the repo (you’ll only need to do this for these files once).

3) Make some changes to your files. Go back to TortoiseHg. Click on “Working Directory”. Be amazed that it sees the changes.

4) Commit those changes.

5) To roll back, right-click the initial commit. Click “Update” (as in “Update the folder to be like it was at this point in time). Go back to your folder. Be amazed — all the files have been changed back to the way they were at that point in time.

6) You can Update back to the second commit, if you want.

7) Go to BitBucket. Create a free academic account.

8) In BitBucket, look for a drop-down menu that has two options: HTTPS and SSL. These are the addresses for Pushing to (and Pulling from) your repository. Use the HTTPS option. Copy the address.

9) To push to and pull from your BitBucket account, I still think it’s easier to use the command line:
* Open a Terminal/Command Prompt window.
* Type (without the outside quotes) `cd path/to/your/mercurial-tracked/folder` (cd = “Change directory”). In Windows, you may need to use back-slashes (\) instead of forward-slashes (/).
* To push: Type `hg push https://jlev_uo@bitbucket.org/blahblahblah` (whatever you copied from BitBucket) (hg = Mercurial. Get it? Like Mercury?)
* To pull: Type `hg pull https://jlev_uo@bitbucket.org/blahblahblah` (whatever you copied from BitBucket)

10) Note that you can make your BitBucket repo public or non-public — you can set this under the configuration page for that repo.

4 comments

  1. rosem@uoregon.edu

    Excellent! Thank you, Jacob!
    If you got through the week 1 practice problems (or if you’re having trouble getting through them and would like feedback), go ahead and make a bitbucket account and post your code. The easiest way to do that is probably to edit the practice problems document itself (which you can do right in the R editor) and post that. Then take a look at other people’s code and see what they did differently from you, if they’re having problems you can help with, etc.
    Happy R-ing!

  2. Pingback: Week 6 Materials: Catch Up and Review | R Club

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>