Friday 24 August 2012

Setting up Git for writing papers

One more technical post before getting on with more research stuff next week. Writing papers in LaTeX is made far easier with some kind of versioning system. Now I don't have any particular favorites and if there is some kind of institutional system set up then you should probably go with that to save some headaches. However, there are often delays with getting new people from outside the institution into the system so there is some incentive to run your own.

I recommend gitolite especially if you are on some version of linux. All you need is a box which people can access via ssh. The cool part is you don't need to give people an account on your machine you just get them to send you their public keys.

First make an account -  call it git_admin but you can name it anything you wish. As root

>># adduser git_admin
>># passwd git_admin

download and install gitolite, if you are on a major distribution (fedora, ubuntu, etc.) there will be a package

Next generate a public-private key for git_admin -
>> su - git_admin
>> ssh-keygen
>> cp ~/.ssh/id_rsa.pub /tmp/git_admin.pub

make sure to name the file username.pub

login to gitolite - again as root
>># su - gitolite
>>gl-setup /tmp/git_admin.pub

got back to the git-admin account and do
>>git clone gitolite@localhost:git-admin

if you want the admin files on a different machine replace localhost with the appropriate ip address/name

Now to add a repo go to git-admin/conf/gitolite.conf

add the line:

repo repository_name
         RW+    =     username

to add a user simply add the public key file to the keydir directory, do a git add, commit, and push and there you've got a personal git repository.

PS - if you are new to git that means

>> git add username.pub
>> git commit -a -m"some informative message"
>> git push

if git complains about you not having an identity, run
>> git config user.name "my name"
>> git config user.email "some@email.here"

both of these should be set to something.

and finally, once you clone an empty repository make some dummy file such as a readme, then to do
>> git add readme
>> git commit -a -m"some msg"
>> git push origin master


All this information is on the internet already but not in one place...so hopefully it helps.





No comments:

Post a Comment