安装配置git服务器
sudo useradd -m git
sudo mkdir /home/repo
sudo chown git:git /home/repo
sudo chmod 700 /home/repo
git config –global “myname”
git config –global user.email “myname@server “
sudo apt-get install python-setuptools
cd /tmp
git clone git://
cd gitosis
sudo python setup.py install
su git
$ ln -s /home/repo /home/git/repositories
$ exit
ssh-keygen -t rsa
将公钥拷贝到服务器的/tmp下:
scp .ssh/id_rsa.pub
sudo chmod a+r /tmp/id_rsa.pub
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
Initialized empty Git repository in /home/repo/gitosis-admin.git/
Reinitialized existing Git repository in /home/repo/gitosis-admin.git/
sudo passwd root
su
# cd repositories
# cd gitosis-admin.git/
# sudo chmod 755 /home/repo/gitosis-admin.git/hooks/post-update
# exit
在服务器上新建一个测试项目仓库我建了一个叫“teamwork” 的仓库。
切换到git用户:
a@ubuntu:/home/git$ su - git
$ cd /home/prj_git
$ mkdir teamwork.git
$ cd teamwork.git
$ git init --bare
$ exit
刚刚提到,gitosis本身 的配置也是通过git来实现的。在你自己的开发机里,把gitosis-admin.git这个仓库clone下来,就可以以管 理员的身份修改配置了。
git clone
fatal: The remote end hung up unexpectedly
# cp /path/to/.ssh/id_rsa.pub ./keydir/b.pub
# exit
[gitosis][group gitosis-admin]
writable = gitosis-admin
members =[group hello]
writable = teamwork
members = b[group hello_ro]
readonly = teamwork
members = lz
team组有a,b两个成员,该组对teamwork仓库有读写权限;
team_ro组有lz一个成员,对teamwork仓库有只读权限。
加入新文件、提交并push到git服务器:
git add .
git commit -am “add teamweok prj and users”
git push origin master
cd teamwork-ori/
git init
git commit -am “initial version”
git push origin master
su b
$ cd /home/b
$ git clone
$ vim hello
$ git add .
$ git commit -am “b add”
$ exit
首先需要从你的工作仓库中得到一个纯仓库, 比如你的工作目录为~/kernel, 你想导出纯仓库到你的优盘里,然后拷贝到gitserver上去。
$ git clone –bare ~/kernel /media/udisk
然后就拿着优盘,交给gitserver的管理员,让他拷贝到/home/repo/下,同时需要配置 gitosis相关配置文件哦,这个就不用再说了吧。比如:下载ALSA库:
git clone git://
git clone git://
git clone –bare alsa-lib alsa-lib.git
git clone –bare alsa-utils alsa-utils.git
1. 安装gitweb
sudo apt-get install gitweb
2. 安装apache2
sudo apt-get install apache2
3. 配置gitweb
(1)默认没有 css 加载,把 gitweb 要用的静态文件连接到 DocumentRoot 下:
cd /var/ www/
sudo ln -s / usr/ share/ gitweb/* .
(注意后 面的点)
(2)修改配置:
sudo vi /etc/ gitweb.conf
将 $projectroot 改为gitosis-admin.git所在目录: /home/git/repositories
(3)修改 /home/git /repositories权限,默认情况下,gitosis将 repositories 权限设置为不可读的
sudo chmod 777 -R /home/git/repositories
11.编辑apache2 配置文件,建立web站点 (默认情况下可以忽略此步 骤)
(1) 编辑apache2配置文件
ubuntu中默认的web目录是/var/www,默认的cgi目录是 /usr/lib/cgi-bin /,安装完成gitweb后,gitweb的gitweb.cgi会自动放置
到该目录下。如果你的 cgi路径不是默认的/usr/lib/cgi-bin/,需要将gitweb安装在/usr/lib/cgi-bin 中的gitweb.cgi复制到原来配置
的cgi-bin路 径,并修改apache的配置文件/etc/apache2/apache.conf:
SetEnv GITWEB_CONFIG /etc/gitweb.conf
gitweb.conf配置文件形如:(可自行修改,这里不做详细介绍)
Options FollowSymlinks ExecCGI
Allow from all
AllowOverride all
Order allow,deny
SetHandler cgi-script
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
(2)重新启动 apache:sudo /etc/init.d/apache2 restart,访问
<以下未经测试>a2dissite gitserver 禁用
a2ensite gitserver 使能
/etc/init.d/apache2 restart 重启
git clone git://
cd git
make GITWEB_PROJECTROOT=”/home/repo” prefix=/usr gitweb/gitweb.cgi
cd gitweb
cp -av git* /home/repo/
ServerName 172.20.146.39
DocumentRoot /home/repo
ScriptAlias /cgi-bin/ /home/repo
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
chmod a+r repo
chmod a+x repo
6./etc/init.d/apache2 restart
git clone
git clone
git访问方式:
git clone
Web网页浏览:
1.windows文件命名不区分大小 写,而linux支持。这样android源码下载时会出现一下问题。大约有15个文件存在这个问题。
2.库的描述文件在.git文件夹的description文件中。编辑该文件,在gitweb页中就会有 description。
3.gitosis库hooks下的post- update不是由post-update.sample重命名过来的,它们不一样。post-update可以更新工作目录,保持与库一致。没有它配置 文件是不会更新的。
4.(1)git@hello:/home/git$ git add .
error: readlink(“external/openssl/apps/md4.c”): No such file or directory
error: unable to index file external/openssl/apps/md4.c
fatal: adding files failed
Initialized empty Git repository in /external/openssl/.git/
# git add .
error: readlink(“apps/md4.c”): No such file or directory
error: unable to index file apps/md4.c
fatal: adding files failed
(3) rm -Rf .repo
find . -name “.git” | xargs rm -Rf