Git

From KevinWiki

(Difference between revisions)
Jump to: navigation, search
Kevin (Talk | contribs)
(Created page with "= Git = == Client-side Installation == In the client, $ apt-get install git-core $ git config --global user.name "GivenName Surname" $ git config --global user.email user@e...")
Newer edit →

Revision as of 20:17, 28 July 2012

Contents

Git

Client-side Installation

In the client,

$ apt-get install git-core 
$ git config --global user.name "GivenName Surname" 
$ git config --global user.email user@email.address 

Server-side Installation

In the server,

$ apt-get install git 

Gitolite

Add User to Manage Gitolite

  1. Add user to manage gitolite
$ adduser \
  --system \
  --shell /bin/bash \
  --gecos 'git version control' \
  --group \
  --disabled-password \
  --home /home/git \
  git

Adding system user `git' (UID 108) ...
Adding new group `git' (GID 110) ...
Adding new user `git' (UID 108) with group `git' ...
Creating home directory `/home/git' ...

Create SSH key

$ ssh-keygen -t rsa 

/home/username/.ssh/some_git_rsa [ENTER] [ENTER]

Transfer SSH Keys to Server

$ ssh-copy-id '-p PORT_NUMBER -i /home/user/.ssh/some_git_rsa.pub git_user@host' 

If it doesn't work because the user is the only user who can access the server with his/her ssh key so accessing with git_user doesn't work.

$ scp -P PORT ~/.ssh/some_git_rsa.pub user@host: 

Log in with the user account

$ ssh -p PORT user@host
$ mv some_git_rsa.pub git.pub 

Setup

$ su - git 
$ cd ~ 
$ echo "PATH=$HOME/bin:$PATH" > ~/.bashrc
      1. don't need this these 2 lines
$ mkdir .ssh 
$ cat /home/user/git.pub >> /home/git/.ssh/authorized_keys 
$ exit

Gitolite Installation

$ sudo -i 
$ apt-get install gitolite 

Setup git User

$ su - git
$ gl-setup /home/user/git.pub 
$ vim /etc/ssh/sshd_config 

Add git to the allowed user

AllowUsers user git

Restart ssh

$ service ssh restart 

Test

    1. Testing (from user local machine)
$ ssh -p PORT_NUMBER git@host 

Having many keys?

$ ssh -p PORT_NUMBER -i ~/.ssh/user@host1.pub git@host 
$ mkdir some-git-repo 
$ git clone git@host:gitolite-admin 

Or if you use a specific port,

$ git clone ssh://git@host:PORT_NUMBER/gitolite-admin 


Add Git User (through Gitolite)

Adding User

$ cd gitolite-admin/keydir 
$ mkdir user_name 
$ cp ~/.ssh/user@host1.pub .
$ cp ~/.ssh/user@host2.pub .
$ git add user@host1.pub 
$ git commit -a -m "users added: user@host1 and user@host2" 
$ git push
Retrieved from "http://kevinlee.io/wiki/Git"
Personal tools