Differences between revisions 8 and 9
Revision 8 as of 2016-05-18 15:15:48
Size: 2900
Editor: MattJohnson
Comment:
Revision 9 as of 2016-05-18 15:26:55
Size: 4410
Editor: MattJohnson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:

* Next: You need to get a copy of the code on your machine. If you go into the project's overview on Bitbucket (should have an URL like: `https://bitbucket.org/MyBitbucketUserName/project_name`), you should see a little box near the upper right containing a link that looks something like this: `https://MyBitbucketUserName@bitbucket.org/SomeBitbucketUserName/project_name.git` . That is the URL you can use to get your own copy of the repository. (A repository is basically a copy of the current version of the code, along with some invisible metadata containing the history of all previous changes made to the code.) So select the link and copy it to your clipboard.

* Now open your Terminal (assuming you are on a Mac). There are non-Terminal ways to use Git, but if you are doing enough programming to use Git, you should just be using the command line. Navigate to whatever directory you want to keep your copy of the code in. (For example, Matt keeps all his coding projects in ~/Desktop/dev but you can put it wherever your heart desires.) Then enter the following command: `git clone https://MyBitbucketUserName@bitbucket.org/SomeBitbucketUserName/project_name.git` where the link part is whatever you copied from Bitbucket. You will probably be asked for your Bitbucket password, and if everything goes according to plan, you will see some download progress information, and then at the end you'll have a new folder named `project_name` (for whatever the project is called) with the code in it.

A lot of what we do involves writing code in some way. When you write code, especially in a group project but even when on your own, it is SUPER-useful to do some kind of source code management (SCM) -- basically, this means using a tool that keeps track of the various changes that different people are making to the code base. Even when only one person is writing the code, SCM helps you keep track of what you have changed since the last "stable" version of your code; anyone who has done a significant amount of programming will be aware of how crazy things can get when you lose track of what you have changed since the last time the code actually worked like it was supposed to.

Anyway, the SCM tool we mostly use is probably also the most common one nowadays, namely Git. What follows is a quickie guide to getting started with Git. It is a really powerful tool, which is a euphemism for "it can be really complicated to use", but 90% of the time you'll just be using a handful of commands. So here's the quick-start guide.

* For reference: If you need more detail than you get here, this is the official Git documentation. Be forewarned that it goes into more detail than you probably need right now.

* For more tutorial-type content: You might try this course on Codecademy. I (Matt) haven't personally tried it but most of Codecademy's stuff is pretty decent. (If you, dear reader, do try it, feel free to edit this article and add your thoughts/notes.)

* On to getting started. First thing to do is make sure you have Git. If you are using a Mac, which you should be if you are in this lab, you already have Git pre-installed. If you are using Linux, you probably have it too (or you are a big enough nerd that you already know how to install packages and can easily do so). If you are using Windows, may God have mercy on your soul. So... for right now we're going to assume you have it.

* Second thing: You don't have to use a website or service to host your code, but there are many benefits to doing so. You may have heard of sites like GitHub or Bitbucket that host repositories of code for you -- we tend to use Bitbucket. To use Bitbucket, you need an account. And then someone in the lab will need to invite you to be a member of whatever project you are working on. So, you can either sign up for a Bitbucket account and then send Matt/Rafay/whoever your username so they can add you, or just send Matt/Rafay/whoever the email address you plan to use to register on Bitbucket. (If you just send them your email address, the invitation email from Bitbucket will then let you create an account with that email address.) Either way, at the end of this step, you will have a Bitbucket account, and someone in the lab will have added you to the relevant project(s).

* Next: You need to get a copy of the code on your machine. If you go into the project's overview on Bitbucket (should have an URL like: https://bitbucket.org/MyBitbucketUserName/project_name), you should see a little box near the upper right containing a link that looks something like this: https://MyBitbucketUserName@bitbucket.org/SomeBitbucketUserName/project_name.git . That is the URL you can use to get your own copy of the repository. (A repository is basically a copy of the current version of the code, along with some invisible metadata containing the history of all previous changes made to the code.) So select the link and copy it to your clipboard.

* Now open your Terminal (assuming you are on a Mac). There are non-Terminal ways to use Git, but if you are doing enough programming to use Git, you should just be using the command line. Navigate to whatever directory you want to keep your copy of the code in. (For example, Matt keeps all his coding projects in ~/Desktop/dev but you can put it wherever your heart desires.) Then enter the following command: git clone https://MyBitbucketUserName@bitbucket.org/SomeBitbucketUserName/project_name.git where the link part is whatever you copied from Bitbucket. You will probably be asked for your Bitbucket password, and if everything goes according to plan, you will see some download progress information, and then at the end you'll have a new folder named project_name (for whatever the project is called) with the code in it.

rapwiki: UsingGit (last edited 2016-05-18 16:16:31 by MattJohnson)