Git-NECI

From CUC3
Revision as of 17:19, 1 October 2009 by import>Ajwt3
Jump to navigation Jump to search

Git and NECI

I've been discussing this for a while, and I'm keen to do a trial run to see if people are comfortable with using git. The move-over from svn to git is reasonably painless, but it isn't possible to easily use both svn and git from more than one repository. I'll therefore maintain the connection with the svn (through git-svn) until such time as we might transfer fully. The upshot of this is that the changes may take a day to filter through back and forth between git and svn versions. If you use just one or the other then changes will be immediate.

I'm going to host it on my home on scepter. Access will be via ssh. At the moment, I'd like people to test checking it out, and see how it would fit into their workflow. I've included some rudimentary instructions below, but there are some tutorials online (e.g. http://git.or.cz/course/svn.html ), and man gittutorial also provides some help. I would advise creating your own local sandbox repository to play and test things out on (separate from NECI).

To get it up and running successfully, it's sensible to have a public key setup (see below). After that, try the checkout commands below.

You may also find JSS's Git page useful. --alex 17:04, 1 October 2009 (BST)

Public Key Setup

You can see if you have one with

ls ~/.ssh/id_?sa.pub

If you don't, you can generate one with:

ssh-keygen -t dsa

I'm a security slacker, so I don't use a passphrase, but I'm sure JSS can let you know about exciting combinations of keyrings and passphrases if you want to use them

You can copy the key to scepter (if you have an rsa, change dsa to rsa)

scp ~/.ssh/id_dsa.pub @scepter:
ssh scepter
cat ~/id_dsa.pub >>~/.ssh/authorized_keys
rm ~/id_dsa.pub
exit

Now test whether you can access scepter without a password

ssh scepter

Setting up git prompts

There's a nice little prompt utility which allows you to add git to your prompt.

wget "http://repo.or.cz/w/git.git?a=blob_plain;f=contrib/completion/git-completion.bash;hb=HEAD" -O ~/.gitprompt.bash

then in your .bashrc add to the end:

source .gitprompt.bash
export PS1='\u@\h:\w$(__git_ps1 " [%s]")\$ '

Feel free to customize your prompt otherwise. Mine is

export PS1="\[\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~} ${STY}\007\]\u@\h:\w$(__git_ps1 " [%s]")\$"

Cloning the NECI repository

Go to your favourite directory

cd ~/NECI
git clone scepter:~ajwt3/NECI.git SOURCEgit

This will create a directory ~/NECI/SOURCEgit

You'll want to use the following commands for the moment

git status
git commit
git pull
git push
git help 
git help status (etc.)

Eventually there will be branching and merging (next week hopefully). Then we can have some real fun. DO NOT USE git svn on this repository. It will likely break things horribly owing to creating multiple different histories.

--alex 17:00, 1 October 2009 (BST)

Initial Setup

Some information on how this repository was setup initially

ajwt3@scepter:~> mkdir NECI.git
ajwt3@scepter:~> cd NECI.git
ajwt3@scepter:~/NECI.git> git init --bare --shared=group
Initialized empty shared Git repository in /home/ajwt3/NECI.git/
ajwt3@scepter:~> cd ..
ajwt3@scepter:~> chgrp -R alavi NECI.git/
ajwt3@scepter:~> chmod -R g+w NECI.git/

Then back to ajax

ajwt3@ajax:~/NE-CI/SOURCE [master]$ git remote add origin scepter:~ajwt3/NECI.git
ajwt3@ajax:~/NE-CI/SOURCE [master]$ git push origin master
ajwt3@ajax:~/NE-CI/SOURCEgit2 [master]$ cd ..
ajwt3@ajax:~/NE-CI$ git clone scepter:~ajwt3/NECI.git SOURCEgit2
ajwt3@ajax:~/NE-CI$ cd SOURCEgit2/
ajwt3@ajax:~/NE-CI/SOURCEgit2 [master]$ 

Thanks to JSS for pointing out the bare and shared flags. --alex 17:19, 1 October 2009 (BST)