Ubuntu下安装git server
来源:互联网 发布:重生之女土匪知乎 编辑:程序博客网 时间:2024/06/16 00:27
1.更新:防止安装git依赖包时出错
sudo apt-get update
sudo apt-get upgrade
2.安装openssh和openssh-client:安装问题详见我的其他博客
3.安装git
sudo apt-get install git-core
4、配置git用户
在Ubuntu Server上新增一个git用户,用于为安装gitosis做准备
$ sudo adduser --system --shell /bin/bash --group git // 创建用户 git,并设置用户的 shell 为可登录的 shell,如 /bin/bash,同时添加同名的用户组。
$ sudo adduser git ssh // 有的系统,只允许特定的用户组(如 ssh 用户组)的用户才可以通过 SSH 协议登录,这就需要将新建的 git 用户添加到 ssh 用户组中。
$ sudo passwd git // 为 git 用户设置口令。
$ ssh-copy-id git@server // 管理员在客户端使用下面的命令,建立无口令登录。
5、创建git Server的仓库存储
$ sudo mkdir /home/git/repositories // 创建git仓库存储目录
$ sudo chown git:git /home/git/repositories // 设置只允许git用户才能访问此目录
$ sudo chmod 755 /home/git/repositories // 设置目录访问的可读写或执行的权限
初始化一下服务器的git用户,这一步其实是为了安装gitosis做准备。在任何一 台客户端机器上使用git,第一次需要初始化一下:
$ git config --global user.name "name" // 例如:james
$ git config --global user.email "name@server" // 例如:james@yahoo.com
6、获取Gitosis,并安装
Gitosis 就是一套用来管理 authorized_keys
文件和实现简单连接限制的脚本。简单地说,Gitosis就是git的权限策略控制器。
因为Gitosis源码安装方式通过python方式,所以这里要检测是否安装了python的setup tool,没有即安装此工具, 这个也是为了gitosis做准备:
$ sudo apt-get install python-setuptools
去到一个临时目录
$ cd /tmp
$ git clone https://github.com/res0nat0r/gitosis.git // 下载Gitosis的源代码
$ cd /tmp/gitosis
$ sudo python setup.py install
说明:Gitosis有一个改进的升级版Gitolite,这里以安装Gitosis为标准,所以不对Gitolite介绍。Gitosis安装完之后,即Git服务器就安装完成,接下来,需要为Git设置一个管理员,通过Gitosis初始化之后,才能正常使用Git作为版本控制进行相关版本管理。
usr@pc1:~$ ssh-keygen -t rsa
a@server:/tmp/gitosis$ sudo -H -u git gitosis-init </home/zouyu/.ssh/id_rsa.pub
su
sudo chmod 755 /home/git/repositories/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的配置文件
刚刚提到,gitosis本身的配置也是通过git来实现的。在你自己的开发机里,把gitosis-admin.git这个仓库clone下来,就可以以管理员的身份修改配置了。
usr@pc1:~/work$ git clone git@<server>:gitosis-admin.git
fatal: The remote end hung up unexpectedly
root@server:/home/a/work/gitosis-admin # cp /path/to/.ssh/id_rsa.pub ./keydir/b.pub
root@server:/home/a/work/gitosis-admin # exit
[gitosis][group gitosis-admin]
writable = gitosis-admin
members = a@server usr@pc1[group hello]
writable = teamwork
members = a@server b[group hello_ro]
readonly = teamwork
members = lz
team组有a,b两个成员,该组对teamwork仓库有读写权限;
team_ro组有lz一个成员,对teamwork仓库有只读权限。
加入新文件、提交并push到git服务器:
usr@pc1:~/work/gitosis-admin$ git add .
usr@pc1:~/work/gitosis-admin$ git commit -am “add teamweok prj and users”
usr@pc1:~/work/gitosis-admin$ git push origin master
初始化测试项目
usr@pc1:~/work$ cd teamwork-ori/
usr@pc1:~/work/teamwork-ori$ git init
usr@pc1:~/work/teamwork-ori$ git commit -am “initial version”
usr@pc1:~/work/teamwork-ori$ git push origin master
usr@pc1:~/work/teamwork-ori$ su b
$ cd /home/b
$ git clone git@<server>:teamwork.git
$ vim hello
$ git add .
$ git commit -am “b add”
$ exit
添加已有git项目
首先需要从你的工作仓库中得到一个纯仓库, 比如你的工作目录为~/kernel, 你想导出纯仓库到你的优盘里,然后拷贝到gitserver上去。
$ git clone –bare ~/kernel /media/udisk
然后就拿着优盘,交给gitserver的管理员,让他拷贝到/home/repo/下,同时需要配置 gitosis相关配置文件哦,这个就不用再说了吧。比如:下载ALSA库:
git clone git://android.git.kernel.org/platform/external/alsa-lib.git
git clone git://android.git.kernel.org/platform/external/alsa-utils.git
git clone –bare alsa-lib alsa-lib.git
git clone –bare alsa-utils alsa-utils.git
配置gitweb
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配置文件形如:(可自行修改,这里不做详细介绍)
<Directory "/srv/www/cgi-bin/gitweb">
Options FollowSymlinks ExecCGI
Allow from all
AllowOverride all
Order allow,deny
<Files gitweb.cgi>
SetHandler cgi-script
</Files>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
</Directory>
(2)重新启动apache:sudo /etc/init.d/apache2 restart,访问http://localhost/cgi-bin/gitweb.cgi
<以下未经测试>
a2dissite gitserver 禁用
a2ensite gitserver 使能
/etc/init.d/apache2 restart 重启
git clone git://git.kernel.org/pub/scm/git/git.git
cd git
make GITWEB_PROJECTROOT=”/home/repo” prefix=/usr gitweb/gitweb.cgi
cd gitweb
cp -av git* /home/repo/
<VirtualHost 172.20.146.39:80>
ServerName 172.20.146.39
DocumentRoot /home/repo
ScriptAlias /cgi-bin/ /home/repo
<Directory /home/repo>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script cgi
DirectoryIndex gitweb.cgi
</Directory>
</VirtualHost>
chmod a+r repo
chmod a+x repo
6./etc/init.d/apache2 restart
git clone http://192.168.1.1/alsa-lib.git
git clone http://192.168.1.1/alsa-utils.git
git访问方式:
git clone git@192.168.1.1:alsa-lib.git
Web网页浏览:
http://192.168.1.1
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/
root@/external/openssl # 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) root@android-2.1_r2$ rm -Rf .repo
root@android-2.1_r2 $ find . -name “.git” | xargs rm -Rf
- Ubuntu下安装git server
- ubuntu安装git server
- Ubuntu Server 12.10下安装以及配置Git
- ubuntu 下安装 git
- Ubuntu下安装git
- Git Ubuntu下安装
- ubuntu下安装git
- ubuntu下 安装git
- ubuntu下安装git
- ubuntu下搭建git server
- ubuntu下搭建git server
- ubuntu下git server搭建
- ubuntu安装git server经验总结
- 在Ubuntu下安装git
- ubuntu下git的安装
- ubuntu下git的安装
- Ubuntu下安装git工具
- UBUNTU 下GIT的安装
- Navicate for MySQL下载和注册码
- Android基础总结——进程优先级及提高优先级的方法(Service尽量不死之法)
- Runtime的使用2 【method swizzling】
- 觉得有用的c和C++在线教程地址
- js运动技术--多物体运动框架(变宽、变高、改变字体、改变border、透明度)以及替换offset的使用
- Ubuntu下安装git server
- mysql dateTime字段在记录更新时随之更新
- base64操作照片字符串之间的转换
- 在JQ上定义滚动条插件
- Python3 asyncio 例程
- BeanFactory介绍
- EasyUI Datagrid 动态合并单元格
- Matchbox总结
- GAT新Bug:点击分页按钮页面没变