Getting Started with GIT

Reviewed by bil hays, 02.27.2017

If you haven’t started using a software repository system, you might find the following useful. Repos like cvs, svn, and git allow for version control, restoration of snapshots, and facilitate multiple people working on a project without getting in each others way. We recommend git, but some of you alluded to past bad experiences with git. git doesn’t work well with large datasets (it is for source code) and it can be complex and frustrating, especially when the remote and local repos differ. I’ve heard also that it doesn’t play well with the Unity game development platform. So it’s not the tool for every problem, and we support svn and cvs if you’re rather use one of those.

Mike Reiter sent me this link, which is a pretty wonderful rant about git. The comments are also very good:
https://reprog.wordpress.com/2010/05/12/still-hatin-on-git-now-with-added-actual-reasons/

And for data, something I just stumbled upon is the data project. It’s in beta and looks interesting:
http://datproject.readthedocs.org/en/latest/

Also, we have a server supporting this software, information on that service is in the link below. Use of this service is highly recommended, your repos will be backed up, and since this is not part of your afs home directory, it eases transition for your software after you graduate or otherwise move on.

These links may help you get started:
http://cs.unc.edu/help-article/cvs-repositories/
http://www.sitepoint.com/introduction-to-git-1/
https://training.linuxfoundation.org/free-linux-training/linux-training-videos/introduction-to-git
https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

You will need to make a public/private key pair for access to the cs git repositories. If you have a public/private keypair already, send help@cs.unc.edu the public key (not the private key) and we’ll get you set up.

Use a SSH to login to the classroom.cs.unc.edu linux server. You’ll want to make a directory that only you can access in your afs home directory. AFS has to be able to read your .ssh folder so you don’t want to use that for private keys:

mkdir .ssh-private
fs sa .ssh-private system:administrators none
fs sa .ssh-private system:anyuser none

then run
fs la  .ssh-private

And see that only you have permissions to use that directory. This is not an issue on your personal machines, on cs.unc.edu OS X boxen, or on cs.unc.edu windows machines, since we don’t use AFS home directories on these systems, but you need to do this on the CS login servers.

Create the key pair thusly:

/usr/bin/ssh-keygen -t rsa -N ” -b 4096 -C ‘<Put your CS userid here>@cs.unc.edu’ -f ~/.ssh-private/<Put your CS userid here>@cs.unc.edu.rsa

comment (-C) should be your email address. Note that there are two single quotes with nothing between them, this creates a key without a passphrase. Send me a copy of the key that ends in .pub and I’ll install it on the git server.

It’s very important that you keep close guard of the private key. If you want to use the same private key on your personal machines make sure to use a secure method such as sftp to copy it.

If you’re using mac/linux, when you login and want to use git, you would add your private key to an ssh-agent using something like this:
eval $(ssh-agent)
ssh-add /Users/hays/.ssh/hays@cs.unc.edu.rsa

You can verify that the key is loaded with
ssh-add -l

If you want to use git on windows, you need to convert the key. Here are some instructions:

SourceTree for Windows with SSH key files

Short version is you go to the putty project and download putty-gen and pageant.
-Copy the private key to the windows machine in a safe place
-Rename it with a .ppk extension
-Use putty-gen to convert to a key putty can use
-Use pageant to load the key into ram, pageant is basically an ssh agent for windows

Sourcetree is a good choice of git client, it’s cross platform.