Welcome
Welcome to refracta

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

gitolite server

Tips and Instructional topics. Not for support questions.

gitolite server

Postby nadir » Sun Oct 21, 2012 3:28 pm

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

In pathes all "-" need to be replaces by a "/".

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.

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 [email protected]_server_name


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


on client:
Code: Select all
        $ git clone [email protected]_server_name:repositories-gitolite-admin.git




(to administer, push and pull accordingly)
or
Code: Select all
        $ git clone [email protected]_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 [email protected]_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 you changed the file called vimrc):

Code: Select all
        git add vimrc

or with the hammer:
Code: Select all
    git add *


commit the change
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
Code: Select all
    git status



Remote connections with
Code: Select all
    git remote



Which branch with
Code: Select all
    git branch



but first you need a second branch:
Code: Select all
    git branch testing



Code: Select all
    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
Code: Select all
    git checkout master



to go back to the master branch.
Merging branches is beyond me, but not too hard.

Go back in time (me thinks to your last commit)
Code: Select all
    git stash



And if you want to delete files:
Code: Select all
    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
Code: Select all
    git mv name-of-file new-name

and so forth.

--------------------------------------------------------
--------------------------------------------------------
3) Example file for .ssh
the path delimiter - needs to be replaced by a /
problem with the forum software.
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:
Code: Select all
    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)
So i herd u liek mudkip?
User avatar
nadir
 
Posts: 1160
Joined: Wed Mar 09, 2011 4:18 am
Location: here

Return to How-to

Who is online

Users browsing this forum: No registered users and 0 guests

cron
suspicion-preferred