We will need the following software set up on whatever computer(s) you plan to use for this course. It should all work equally well on Mac, Windows, or Linux. These are somewhat ‘bare bones’ instructions, so use Piazza to ask questions if you encounter any problems.
The first step is to install the Java Software Development Kit (SDK). You may already have a Java Runtime Environment (JRE) if other applications on your system require it, but that is not enough. Unless you have programmed in Java on this system before, chances are you’ll need to install a JDK from scratch.
Start at this link: http://www.oracle.com/technetwork/java/javase/downloads/index.html and scroll down to Java SE 7uXX » JDK » Download — Android might not work with the latest Java 8!
On the next page, you’ll need to accept the license agreement, and then you can find the download link for your platform — probably Windows x64 or Mac OS X.
Go through the Oracle setup wizard; all the defaults are fine. At this point you may be redirected to a web browser to register with Oracle. That is completely optional.
Download Android Studio for your platform, at http://developer.android.com/sdk/index.html
Run the installer — the defaults should be fine. After you start Android Studio for the first time, it will download some additional components. It may even alert you that a new version is already available! Don’t feel you have to update every time a new version is released — in general, if things seem to be working, I’d recommend leaving it alone.
Git is a version control tool, that helps developers keep track of any changes that are made to a set of files. We’ll also use it to submit and collaborate on assignments. You may have heard of GitHub, a social code-sharing site. We’ll be using a similar service called GitLab, which more easily allows private code repositories.
cs164and skip to step 7 below.
Install the Git distributed version control application from http://git-scm.com/downloads. The default settings are fine.
Sign up for an account on GitLab: https://gitlab.com/users/sign_up. Once logged in to your dashboard, create a new private project named
Open the Git bash application on Windows, or use Utilities » Terminal on Mac. Type these commands, replacing your actual name and email address in the double quotes:
git config --global user.name "YOUR NAME" git config --global user.email "email@example.com"
Create an SSH key pair, assuming you don’t already have one on this computer. To do that, in the Git bash terminal, enter
ssh-keygen. You’ll press enter for all the defaults, including an empty passphrase. It should go something like this:
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/league/.ssh/id_rsa): Created directory '/c/Users/league/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/league/.ssh/id_rsa. Your public key has been saved in /c/Users/league/.ssh/id_rsa.pub. The key fingerprint is: b7:27:3e:8d:83:df:9a:21:c7:27:0d:fa:43:ac:d0:7e league@WIN7
Now you’ll want to access the public part of the key that it generated. It’s easiest to open it in a text editor, using:
open -e .ssh/id_rsa.pub
The editor will pop up with a line that begins
ssh-rsa AAAA… copy the whole thing onto your clipboard.
In your GitLab account, go to Profile settings » SSH Keys » Add SSH Key and paste your key in the big box, then Add Key.
On your computer, open the Git GUI application. Select Create New Repository. In the Directory box, browse to somewhere convenient such as Desktop or Documents, and then manually add
/cs164 onto the end (without creating that folder). In my example, the Directory is
You should now see the repository status viewer. You will interact with this interface whenever you want to save your work and synchronize it to the GitLab server.
Create a new file called
readme.txt and save it within the new
cs164 folder. In the file, just type your name and whatever else you want.
Switch back to the repository status viewer.
Hit the Rescan button. Your
readme.txt should appear in the upper left area, labeled Unstaged Changes.
Hit the Stage Changed button. The app will confirm and move the
readme.txt to the lower left area, labeled Staged Changes.
Type a message such as “my initial commit” in the lower box labeled Initial Commit Message.
Hit the Commit button. The status bar at the bottom should say something like “Created commit abcdef: my initial commit.”
Another way to see the commit is to select Repository » Visualize master’s history from the menu. Your commit should be highlighted, and the contents of your readme file will also appear there.
After confirming the details, you can close the history viewer.
The next step is to push the new commit up to the GitLab server, which we will configure as a ‘remote’. Go back to your GitLab
cs164 project page and find the SSH URL. It should look something like
firstname.lastname@example.org:USERNAME/cs164.git. Copy that onto the clipboard.
In the repository status viewer, select Remote » Add from the menu.
origin as the Name, and paste your git@gitlab… URL as the Location. Select Initialize Remote Repository and Push, and hit Add.
A successful push should look something like this:
Not allowed command [ignore this] Pushing to email@example.com:USERNAME/cs164.git To firstname.lastname@example.org:USERNAME/cs164.git * [new branch] master -> master updating local tracking ref 'refs/remotes/origin/master' Success
git gui. If it’s asking a yes/no question, type
yesand press enter; then the process should continue.
Now, in some text editor, make a small change to the readme file you saved in
cs164 – just add a one-line message to it. In the repository status viewer, repeat these steps. We’ll use these whenever you have something new to submit or synchronize:
If you reload the project page on GitLab, you should see a summary of the history, with your most recent commit first: “Christopher League pushed to branch master at Christopher League / cs164 … added one line to readme.”
This last step will allow me to see your work. On your GitLab repository page, open up Settings in the left sidebar, and then select Members. Hit the green New project member box, and search for the account named
league. My name should appear. Select that, and add me with access Master, as shown below.
Confirm by hitting Add users.
Congratulations, your Git is working!