Git服务器的Gitosis安装配置及gitignore的使用方法
Git服务器Gitosis安装设置
1、安装 openssh服务器
sudo apt-get install openssh-server openssh-client
2、创建个人公钥和私钥
在默认用户的主目录路径下,运行以下命令,按照提示创建公钥和私钥
ssh-keygen -t rsa
默认生成2048位,如果需要提高安全级别,也可以通过下面的命令创建公钥和私钥
ssh-keygen -t rsa -b 4096
默认情况下,公钥和私钥会保存在~/.ssh目录下,如下所示:
id_rsa id_rsa.pub known_hosts
3、安装 git服务器
sudo apt-get install git-core
4、配置 git服务器
创建git服务器管理用户
sudo useradd -m git
sudo passwd git
创建git仓库存储目录
sudo mkdir /home/git/repositories
设置git仓库权限
sudo chown git:git /home/git/repositories
sudo chmod 755 /home/git/repositories
初始化全局设置
git config --global user.name "myname"
git config --global user.email "myname@server"
5、安装python的setup tool
sudo apt-get install python-setuptools
6、获取并安装gitosis
cd /tmp
git clone https://github.com/res0nat0r/gitosis.git
cd gitosis
sudo python setup.py install
7、配置gitosis
cp ~/.ssh/id_rsa.pub /tmp
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
8、管理gitosis配置
cd ~
git clone git@hostname:用户名/gitosis-admin.git
cd gitosis-admin/
各个用户按照前面提到的办法生成各自的ssh公钥文件后,服务器管理员把所有人的 ssh公钥文件都拿来,拷贝到keydir目录下。
修改gitosis.conf文件,如下所示
[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = a@server1
[group developers]
writable = helloworld
members = a@server1 b@server2
[group test]
readonly = helloworld
members = c@server3
这个配置文件表达了如下含义:gitosis-admin组成员有a,该组对gitosis-admin仓库有读写权限; developers组有a,b两个成员,该组对helloworld仓库有读写权限; test组有c一个成员,对helloworld仓库有只读权限。 当然目前这些配置文件的修改只是在你的本地,你必须推送到gitserver上才能真正生效。 加入新文件、提交并push到git服务器:
git add .
git commit -am "add helloworld project and users"
git remote add origin ssh://git@hostname/helloworld.git
git push origin master
9、安装apache2
sudo apt-get install apache2
10、安装gitweb
sudo apt-get install gitweb
11、配置 gitweb
默认没有 css 加载,把 gitweb 要用的静态文件连接到 DocumentRoot 下:
cd /var/www/
sudo ln -s /usr/share/gitweb/* .
修改配置:
sudo vi /etc/gitweb.conf
将 $projectroot 改为git仓库存储目录(例如:/home/git/repositories),保存后刷新浏览器。
如果没有找到项目,你需要将$projectroot/*.git 的属性改为755,让apache用户有可读权限。可以只改你需要让别人通过web访问的那个git。http://localhost/cgi-bin/gitweb.cgi
修改/etc/gitweb.conf 内容:
# path to git projects (<project>.git)
#$projectroot = "/var/cache/git";
$projectroot = "/home/git/repositories";
# directory to use for temp files
$git_temp = "/tmp";
# target of the home link on top of all pages
$home_link = $my_uri || "/";
# html text to include at home page
$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;
# stylesheet to use
@stylesheets = ("/gitweb/static/gitweb.css");
# javascript code for gitweb
$javascript = "gitweb/static/gitweb.js";
# logo to use
$logo = "/gitweb/static/git-logo.png";
# the 'favicon'
$favicon = "/gitweb/static/git-favicon.png";
# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();
12、配置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
<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>
Git使用gitignore建立项目过滤规则
在进行协作开发代码管理的过程中,常常会遇到某些临时文件、配置文件、或者生成文件等,这些文件由于不同的开发端会不一样,如果使用git add . 将所有文件纳入git库中,那么会出现频繁的改动和push,这样会引起开发上的不便。
Git可以很方便的帮助我们解决这个问题,那就是建立项目文件过滤规则。
git中提供两种过滤机制,一种是全局过滤机制,即对所有的git都适用;另一种是针对某个项目使用的过滤规则。个人倾向于第二种。
以我的一个项目为例,该项目用.net开发,.config文件、包括生成的bin/Debug, bin/Release文件等,我希望不加入git管理。
在代码目录下建立.gitignore文件:vim .gitignore ,内容如下:
#过滤数据库文件、sln解决方案文件、配置文件
*.mdb
*.ldb
*.sln
*.config
#过滤文件夹Debug,Release,obj
Debug/
Release/
obj/
然后调用git add. ,执行 git commit即可。
Git服务器的Gitosis安装配置及gitignore的使用方法的更多相关文章
- 阿里云服务器Linux CentOS安装配置(零)目录
阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...
- 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署
阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...
- 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定
阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...
- 阿里云服务器Linux CentOS安装配置(七)域名解析
阿里云服务器Linux CentOS安装配置(七)域名解析 1.购买域名 登录阿里云,左侧菜单点击[域名],然后[域名注册],完成域名购买.(一般首年45元) 2.添加域名解析 在域名列表里点击你的域 ...
- 阿里云服务器Linux CentOS安装配置(六)resin多端口配置、安装、部署
阿里云服务器Linux CentOS安装配置(六)resin多端口配置.安装.部署 1.下载resin包 http://125.39.66.162/files/2183000003E08525/cau ...
- 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署
阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...
- 阿里云服务器Linux CentOS安装配置(四)yum安装tomcat
阿里云服务器Linux CentOS安装配置(四)yum安装tomcat 1.yum -y install tomcat 执行命令后,会帮你把jdk也安装好 2.tomcat安装目录:/var/li ...
- 阿里云服务器Linux CentOS安装配置(三)yum安装mysql
阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...
- 阿里云服务器Linux CentOS安装配置(二)yum安装svn
阿里云服务器Linux CentOS安装配置(二)yum安装svn 1.secureCRT连接服务器 2.先创建一个文件夹,用来按自己的习惯来,用来存放数据 mkdir /data 3.yum安装sv ...
随机推荐
- [转帖收集] Java注解
1.Annotation 它的作用是修饰编程元素.什么是编程元素呢?例如:包.类.构造方法.方法.成员变量等.Annotation(注解)就是Java提供了一种元程序中的元素关联任何信息和任何元数据( ...
- iOS开发之--storyboary下,拖拽一个tableview/collectionView/view 等,顶端下沉64个像素的处理方法
大家可能会发现,在sb或者xib里面拖拽一个tableview/collectionview/view的,顶端会自动下沉64个像素,也就是说,运行在模拟器上去,自导航下面又自动下沉了64个像素, 那是 ...
- 面试题思考:Cookie 和 Session的区别
面试回答: 1.cookie数据存放在客户的浏览器上,session数据放在服务器上. 2.cookie不是很安全,别人可以分析存放在本地的cookie并进行cookie欺骗,考虑到安全应当使用ses ...
- jupyter 修改工作路径
在所需打开的目录中新建一个runJupyter.bat文件 将内容修改为: cd ......jupyter notebook 注1:上述两行中,第一行的......为路径(可以不添加,可空着不填), ...
- 【BZOJ1996】[Hnoi2010]chorus 合唱队 区间DP
[BZOJ1996][Hnoi2010]chorus 合唱队 Description Input Output Sample Input 4 1701 1702 1703 1704 Sample Ou ...
- CSS 伪元素 使用参考
伪元素可以做得事情是非常多的,详情大家可以参考这里 大放异彩的伪元素——可以做什么? 本篇主要讲两个伪元素:before和:after的几个要点: 1.:before和:after是加在元素的里面,也 ...
- “绝对”妹纸~position
CSS:布局之fixed,relative,absolute 记住abs是跟随 relative的,没有看到position:relative;之前他会一直向上查找. 直到执着的找到relative! ...
- 3.php数据类型中NULL,"",0的比较
<?php //赋值 $some1 = NULL; $some2 = 0; $some3 = ""; //0与NULL比较 echo $some1==$some2; echo ...
- Qt隐式共享与显式共享
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/Amnes1a/article/details/69945878Qt中的很多C++类都使用了隐式数据共 ...
- windows钩子 Hook示例
1.首先编写一个 win32 dll工程. #include "stdafx.h" int WINAPI add(int a,int b) { return a+b; } BOOL ...