Tips and Instructional topics. Not for support questions.
Post a reply
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## gitolite server

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:
  `adduser git
  apt-get install gitolite`

on client

Code:
  `apt-get install git
  ssh-copy-id -i ~-.ssh-to_gitolite_rsa.pub [email protected]
  _server_name`

on server:

Code:
  `su git
  gl-setup <to_gitolite_rsa.pub>`

on client:

Code:
  `$ git clone [email protected]
  _server_name:repositories-gitolite-admin.git`

(to administer, push and pull accordingly)
or

Code:
  `$ git clone [email protected]
  _server_name:repositories-testing.git`

To create new git-repos
server:

Code:
  `su git
  cd ~-repositories
  mkdir name_of_project && cd !$
  git –bare init
  `

client:

Code:
  `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:
  `git add vimrc`

or with the hammer:

Code:
  `git add *`

commit the change

Code:
  `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:
  `git pull git-server-name master`

You can list the status with

Code:
  `git status`

Remote connections with

Code:
  `git remote`

Which branch with

Code:
  `git branch`

but first you need a second branch:

Code:
  `git branch testing`

Code:
  `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:
  `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:
  `git stash`

And if you want to delete files:

Code:
  `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:
  `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:
  `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:
  `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)
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.