Using Git
Using the Vision Git server
Git (git-scm.com) is a distributed version control system that you can use to manage your projects. In general, you will want to create a separate git respository for each project. Multiple users (both at Caltech and external) can collaborate on a project once access permissions are correctly set.
Adding a Repository
So you want to do some source code management and version control your code? In the Vision Lab, we Git to manage our source code. We also use Gitolite, which is a server for managing fine-grained access control to our central repositories (so that we can restrict who has access to which repositories).
If you want to create a repository to manage your code, or change user permissions for an existing repository, contact the current gitolite admins in the vision group:
- Steve Branson: sbranson@caltech.edu
- Eyrun Eyjolfsdottir: eeyjolfs@caltech.edu
If you want us to create a new repository for you, please INCLUDE THE NAME that you want us to use for your repository. The name should be brief and descriptive, for example "Visipedia-Webapp", or "JCTrax" or "bbLabeler".
But, read the next section BEFORE doing so.
Generating a Public Key
Gitolite uses RSA public keys to authenticate users -- there are no passwords. You have to generate a public/private "key pair" and send your git admin the public key so that he can add it to the server.
A brief security note:
Your private key should be kept really safe; anyone who can access that can impersonate you. Lock your desktop when you leave it for longer than a few minutes, etc. You can protect your private key with a pass-phrase if you wish. You can use something called ssh-agent to avoid typing in the pass-phrase for every operation that accesses the server.
With that out of the way, type in the following command:
ssh-keygen -t rsa
- hit enter when it asks you for a filename -- don't change the default
- when it asks you for a passphrase, you have two choices. Either hit enter for "no passphrase", or choose some long string and type it in. Twice.
- On Unix, ssh-agent makes it quite painless to use a passphrase, while keeping your private key secured all the time. This might work on Windows also; I'm not sure.
- the output of that command will be two files: a private key and a public key. You need to send your git admin the public key by email
- the program will clearly say "your public key has been saved in ..." and give a long filename. Send only that file
- do NOT send the private key!! Make sure the file name ends in .pub
- btw, to add key for passwordless ssh, use "cat authorized_keys id_rsa.pub >> authorized_keys_new" (inside .ssh), then rename the authorized_key files
Next, identify yourself to git, so that your name and email show up correctly in commits. Type in the following commands:
git config --global user.name "Your Name Here" git config --global user.email your@email.here
Now wait until the git admin does his part and confirms that your public key has been stored in the server.
Generating a Public Key in Windows from putty
[1] - Do NOT do this, INSTEAD:
- follow Linux instructions to generate private / public key
- copy private key onto windows machine
- load private key in puttygen (available [here])
- puttygen will convert key into format for use w pageant, tortoisegit, etc., save this key somewhere safe and use it :)
Using Git
Once your repository has been created, you can clone it on your machine with the following command:
git clone gitolite@vision.caltech.edu:reponame
See http://git-scm.com/documentation/ for tutorials on using git.
Moving Existing Git Repositories to the Vision Git Server
If you have an existing git repository that you'd like to move to the vision git server, contact the admins with your public key and ask them to create a brand new blank repository. You will then push your existing repository into this blank repository, as follows:
cd your-copy-of-existing-repo # make sure all the branches are correct and no extra stuff, "temp" # branches, etc., are present git push --all gitolite@vision.caltech.edu:reponame git push --tags gitolite@vision.caltech.edu:reponame
where reponame
is the name of the new repository on the vision git server.
(You could also use git push --mirror
instead of separately doing branches
and tags, but that will carry across *your* remote refs also, and typically
you may not want that. Anyway please do a git ls-remote gitolite@vision.caltech.edu:reponame
to
make sure all the stuff you want went through, and is named correctly.)
Moving Existing SVN Repositories to Git
You can import Subversion repositories (with history) into git using the git svn
command. See documentation for details.