gitolite

Share your wisdom. Not for support questions!

Moderator: How-to Curator

gitolite

Postby nadir » March 22nd, 2012, 12:42 am

Discussion/Correction/etc is here: viewtopic.php?f=24&t=1686

Setting up your own git(-olite) server is astonishing easy
(at least compared to using git itself, which is a pain)

Here is what i used:
http://progit.org/book/ch4-8.html
It is clear enough, and this "how-to" is a simple hint how easy it is.

Edit:
0) Ultra short Summary
Install gitolite on the server and add a user called git
Install git on the client and copy your ssh-key to the server
Make a bare git on the server
clone it form the client and set the server to be the remote
start pushing and pulling

1) General Setup
That is what i did and do:

on server:
Code: Select all
adduser git
apt-get install gitolite


on client
Code: Select all
apt-get install git
ssh-copy-id -i ~/.ssh/to_gitolite_rsa.pub git@gitolite_server_name


on server:
Code: Select all
su git
gl-setup <to_gitolite_rsa.pub>


on client:
Code: Select all
$ git clone git@gitolite_server_name:repositories/gitolite-admin.git
(to administer, push and pull accordingly)
or
Code: Select all
$ git clone git@gitolite_server_name:repositories/testing.git


To create new git-repos
server:
Code: Select all
su git
cd ~/repositories
mkdir name_of_project && cd !$
git –bare init


client:
Code: Select all
mkdir name_of_project && cd !$
git init
vi README
git add README
git commit -m “initial setup with README”
git remote add origin git@gitolite-server_name:repositories/name_of_project.git
git push origin master



---------------------------------------------------------------------
---------------------------------------------------------------------
2) Some basic git-usage reminders
If you change a file, the usual way to tell git about it is:
a) add the changes and
b) commit the changes
c) push it to the remote host
You can do it by (say yuo changed the file called vimrc):
Code: Select all
git add vimrc

or with the hammer:
git add *
then
Code: Select all
git commit -m "changed my vimrc file"
git push git-server-name master

to push the master branch to the remote git-server-name
You open your second machine, and to fetch the updates you go to the git-repo and do
Code: Select all
git pull git-server-name master


You can list the status with
git status
Remote connections with
git remote
Which branch with
git branch
but first you need a second branch:
git branch testing
git checkout testing
and foo, you are in the testing branch.
(bork it as much as you like, the master branch will stay sane)
and
git checkout master
to go back to the master branch.
Mergin branches is beyond me, but not too hard.

Go back in time (me thinks to your last commit)
git stash
And if you want to delete files:
git rm name-of-file
(don't delete them with rm, it happens to me all the time and ends in a mess/a lot of work)
Move files
git mv name-of-file new-name
and so forth.

--------------------------------------------------------
--------------------------------------------------------
3) Example file for .ssh
Code: Select all
host my-git-server
hostname 192.168.1.42
user git
port 2222
#ServerAliveInternal 30
ServerAliveCountMax 100
IdentityFile ~/.ssh/to-git-server_rsa

And you would do:
git push my-git-server master
(assuming you picked my-git-server as a remote too, sure)

It might sound like a heck lot of work to keep bookmarks or configs in sync, but once one is used to it, it really is a nice and easy way to keep stuff in sync on the LAN (or, if you like, from work/school/etc)
nadir
 
Posts: 1708
Joined: February 9th, 2011, 8:07 am

Return to HowTo

Who is online

Users browsing this forum: No registered users and 1 guest

x