Git Installation and Setup
Written by Aditya Acharya
In keeping with the class's goal to expose you to some new technologies, we have
decided that Git, not Subversion, will be the source control mechanism used. One big
advantage of Git over Subversion is that it provides each user with a local copy of the repository.
So, there will now be 2 repositories to keep in mind as you develop: your local repository and the
class repository. As you develop, you can commit and revert freely with your local repository, and
have no worries about conflicts. When you're satisfied with what you have done, then you can push
your code to the class repository. This prevents unnecessary commits to the class repository just
for the sake of having a revision to revert to. For a more in depth discussion of Git, see Wikipedia.
Step 1a: Installation on Mac
- Go to http://code.google.com/p/git-osx-installer/
and download git-1.6.6-intel-leopard.dmg from the "Featured Downloads" section or the "Downloads" tab.
- Run git-1.6.6-intel-leopard.pkg and follow the instructions for a standard install.
Step 1b: Installation on Windows
- Go to http://code.google.com/p/msysgit/ and
download Git-1.6.5.1-preview20091022.exe from the "Featured Downloads" section or the "Downloads" tab.
- Run the executable. Just keep clicking "Next" until the installation starts and completes. There are some
scary-looking messages in bright red, but those options are not selected by default, so as long as you don't
change anything you should be fine.
- Go to the desktop and double-click on "Git Bash". This should start a terminal.
- Run this command, substituting in your SUNetID. This command should have quotes:
- ssh-keygen -C "<SUNetID>@stanford.edu" -t rsa
- Accept the default key location, but save the path to that location somewhere, since you might need the
key later in the quarter.
Step 1c: Installation on Ubuntu. Please let us know if you are using some other Linux distribution.
- Start a terminal, and run this command. You may have to enter your password, and just hit "Enter" at every
question to accept the default response.
- sudo apt-get install git-core
- Alternatively, you can use the Synaptic package manager to download the latest git-core package. You might
also want to download the gitk and git-gui packages, which allow for graphical browsing of the git repository.
The qgit application also allows for this.
Step 2: Entering user info into Git. This step is very important because we will not know what you have contributed
if you do not enter this information into Git.
- Start a terminal (Mac or Linux) or the Git Bash (Windows).
- Run these commands, substituting in your name and then your SUNetID. The first command should have quotes.
The second command should not.
- git config --global user.name "<Your name here>"
- git config --global user.email <SUNetID>@stanford.edu
Step 3: Pulling the latest version of the class's repository.
- Start a terminal (Mac or Linux) or the Git Bash (Windows).
- Navigate to the folder where you want to pull the latest version of the class repository to. The repository will be pulled
down as a self-contained folder.
- Run this command, all on one line, substituting in your SUNetID.
- git clone ssh://<SUNetID>@myth.stanford.edu//afs/ir.stanford.edu/class/cs193s/git/repo1
- If you are asked if you are sure whether you want to continue connecting, enter "yes" (no quotes).
- Enter your SUNet password. Once you do this, git will download the latest version of the class's repository as folder named "repo1".
There are lots of git tutorials. Here are a few to get the hang of Git with:
http://www-cs-students.stanford.edu/~blynn/gitmagic/
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
http://www.sourcemage.org/Git_Guide
The text-editor that git uses for comments, etc., is vi. You can find a vi guide here:
http://www.cs.colostate.edu/helpdocs/vi.html
Acknowledgements:
The Windows git setup instructions are courtesy of Kyle Cordes:
http://kylecordes.com/2008/04/30/git-windows-go/.
I found the instructions for "Step 2: Entering user info into Git" at
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html.