Git

$ sudo apt-get install git-core git-doc git-gui gitk
$ git config --global user.name "linguofeng"
$ git config --global user.email linguofeng@msn.com
$ git init                // 初始化一个Git版本库
$ git add .               // 添加文件到版本库(未正式添加)
$ git commit -m 'message' // 提交文件到当前版本库的.git
$ git push                // 提交到仓库

安装依赖

$sudo apt-get install openssh-server

生成SSH KEY

$ ssh-keygen -t rsa -C "linguofeng@msn.com"
$ cp ~/.ssh/id_rsa.pub /tmp/linguofeng@msn.com.pub

创建git用户

$ sudo adduser \
    --system \
    --shell /bin/bash \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
    git

使用git用户登录

$ sudo su git
$ echo "PATH=$HOME/bin:$PATH" > ~/.bashrc
$ cd ~

安装Gitolite

$ git clone git://github.com/sitaramc/gitolite.git
$ mkdir -p ~/bin
$ gitolite/install -to ~/bin
$ gitolite setup -pk /tmp/linguofeng@msn.com.pub

成功的提示

Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh missing; creating a new one
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one

配置(在客户端执行)

$ git clone git@localhost:gitolite-admin.git
$ sudo apt-get install apache2 gitweb highlight

@$ sudo subl /etc/gitweb.conf@

$projectroot = "/home/git/repositories";
$projects_list = "/home/git/projects.list";
$feature{'highlight'}{'default'} = [1];

设置权限

$ sudo usermod -a -G git www-data
$ sudo chmod g+r /home/git/projects.list
$ sudo chmod -R g+rx /home/git/repositories
$ sudo service apache2 restart

添加库到gitweb中显示

@$ subl gitolite-admin/conf/gitolite.conf@

repo demo
    RW+     =   linguofeng@msn.com
    R       =   gitweb                  // 实际会在/home/git/projects.list文件中添加demo.git

打开URL: "http://localhost/gitweb":http://localhost/gitweb

        http://gitref.org/
        http://git-scm.com/book/zh
    

Git修改最后提交的Message

git commit --amend -m "New commit message"