<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://linux-wiki.cn/skins/common/feed.css?301"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
		<id>http://linux-wiki.cn/index.php?action=history&amp;feed=atom&amp;title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89</id>
		<title>配置gitosis（以CentOS为例） - 修订历史</title>
		<link rel="self" type="application/atom+xml" href="http://linux-wiki.cn/index.php?action=history&amp;feed=atom&amp;title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89"/>
		<link rel="alternate" type="text/html" href="http://linux-wiki.cn/index.php?title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89&amp;action=history"/>
		<updated>2026-04-09T09:52:04Z</updated>
		<subtitle>本站上此页的修订历史</subtitle>
		<generator>MediaWiki 1.17.0</generator>

	<entry>
		<id>http://linux-wiki.cn/index.php?title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89&amp;diff=1479&amp;oldid=prev</id>
		<title>Chenxing在2010年12月15日 (三) 21:57</title>
		<link rel="alternate" type="text/html" href="http://linux-wiki.cn/index.php?title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89&amp;diff=1479&amp;oldid=prev"/>
				<updated>2010-12-15T21:57:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一修订&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;在2010年12月15日 (三) 21:57所做的修订版本&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第41行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第41行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;minus;&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;更多的例子请参阅gitosis的文档&amp;lt;ref&amp;gt;[http://swik.net/gitosis gitosis - SWiK]。&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;更多的例子请参阅gitosis的文档&amp;lt;ref&amp;gt;[http://swik.net/gitosis gitosis - SWiK]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/ref&amp;gt; &lt;/ins&gt;。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;每次配置好后，按照Git的风格，'''需要commit、push到服务器端'''。修改是立即生效的。&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;每次配置好后，按照Git的风格，'''需要commit、push到服务器端'''。修改是立即生效的。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Chenxing</name></author>	</entry>

	<entry>
		<id>http://linux-wiki.cn/index.php?title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89&amp;diff=1475&amp;oldid=prev</id>
		<title>Chenxing: 新页面: Git是当下流行的版本控制软件，gitosis使管理Git服务器的流程大大简化。本文以CentOS为例介绍配置gitosis的流程，它也适用于多数发行版。...</title>
		<link rel="alternate" type="text/html" href="http://linux-wiki.cn/index.php?title=%E9%85%8D%E7%BD%AEgitosis%EF%BC%88%E4%BB%A5CentOS%E4%B8%BA%E4%BE%8B%EF%BC%89&amp;diff=1475&amp;oldid=prev"/>
				<updated>2010-12-15T21:54:34Z</updated>
		
		<summary type="html">&lt;p&gt;新页面: &lt;a href=&quot;/wiki/Git&quot; title=&quot;Git&quot;&gt;Git&lt;/a&gt;是当下流行的版本控制软件，gitosis使管理Git服务器的流程大大简化。本文以&lt;a href=&quot;/index.php?title=CentOS&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;CentOS（尚未撰写）&quot;&gt;CentOS&lt;/a&gt;为例介绍配置gitosis的流程，它也适用于多数发行版。...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新建页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Git]]是当下流行的版本控制软件，gitosis使管理Git服务器的流程大大简化。本文以[[CentOS]]为例介绍配置gitosis的流程，它也适用于多数发行版。&lt;br /&gt;
&lt;br /&gt;
{{Hint|如果建立的是公开的版本库，可以直接用[http://GitHub.com/ GitHub]等平台而无需自己架设服务器。}}&lt;br /&gt;
&lt;br /&gt;
==安装软件==&lt;br /&gt;
首先安装git和gitosis，多数发行版的仓库有这两个软件。CentOS则需要先添加EPEL软件仓库。&amp;lt;ref&amp;gt;[http://www.lunix.com.au/blog/install-gitosis-on-centos5/ Howto: Install git, gitosis &amp;amp; gitweb on CentOS 5]&amp;lt;/ref&amp;gt;如果你的发行版里没有这两个软件，就直接去网站上安装吧。&lt;br /&gt;
&lt;br /&gt;
根据不同发行版软件包的不同，安装后系统会做一定的配置。请查看''/etc/passwd''，看看是不是已经出现了新的跟git有关的用户，（比如CentOS中会出现名为'''gitosis'''的用户）。'''如果没有'''，则需要自己添加一个用户，所有跟git代码库有关的读写将通过这个用户完成，如&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo adduser --system --shell /bin/sh --gecos 'git user' --group --disabled-password --home /home/gitosis gitosis &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==准备管理员密钥==&lt;br /&gt;
这里需要说明，gitosis的配置文件是用Git管理的，用户的认证则是通过密钥。首次初始化gitosis时，需要提供一个管理员帐户，该帐户可处于'''任何电脑'''上，用其密钥做为身份标志。&lt;br /&gt;
&lt;br /&gt;
所以要先准备一个管理员密钥，这可以在服务器上做，也可以在客户机上做：&lt;br /&gt;
 ssh-keygen -t rsa&lt;br /&gt;
注意不要修改产生的文件的位置（默认在''~/.ssh/''中），密码可以不输（该密码只是用来保护密钥文件的）。这样将在''~/.ssh''中生成''id_rsa''和''id_rsa.pub''两个文件，前者是密钥（如同密码，注意保护），后者是公钥。如果是在客户机上操作的，需要把公钥传到服务器上。假设这个文件叫''id_rsa.pub''。&lt;br /&gt;
&lt;br /&gt;
==初始化gitosis==&lt;br /&gt;
现在回到服务器上，''id_rsa.pub''已经准备好，当前用户是root。执行如下命令：&lt;br /&gt;
 sudo -H -u gitosis gitosis-init &amp;lt; [path of your id_rsa.pub]&lt;br /&gt;
注意第一个gitosis是git帐户的用户名，如果你的发行版名字不同请做相应更改。-H选项很重要，因为代码库要放到gitosis的Home目录里， 不是root的。&lt;br /&gt;
&lt;br /&gt;
至此，gitosis服务器已经配置完毕，接下来对用户、项目的控制要通过Git完成。&lt;br /&gt;
&lt;br /&gt;
==获取配置文件==&lt;br /&gt;
在刚才生成密钥的电脑上，用git clone获取配置文件&lt;br /&gt;
 git clone gitosis@example.com:gitosis-admin.git&lt;br /&gt;
注意将example.com改成服务器的域名。&lt;br /&gt;
&lt;br /&gt;
我们将得到一个''gitosis-admin''文件夹，它里面有''gitosis.conf''文件和一个叫''keydir/''的子文件夹。&amp;lt;ref&amp;gt;[https://wiki.archlinux.org/index.php/Gitosis Gitosis - Archwiki]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
首先，''keydir/''是存放用户公钥的一些.pub文件，用户名对应pub文件的文件名（不含.pub后缀），要添加用户时，让用户按前面的方法准备一个密钥，并对相应的.pub文件放在keydir里，命好名就行了。&lt;br /&gt;
&lt;br /&gt;
用户权限的管理则是通过这个''gitosis.conf''文件，如以下代码段建一个名为test的组，有t1、t2两个成员，他们可以读写testProj项目：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[group test]&lt;br /&gt;
writable = testProj&lt;br /&gt;
members = t1 t2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
更多的例子请参阅gitosis的文档&amp;lt;ref&amp;gt;[http://swik.net/gitosis gitosis - SWiK]。&lt;br /&gt;
&lt;br /&gt;
每次配置好后，按照Git的风格，'''需要commit、push到服务器端'''。修改是立即生效的。&lt;br /&gt;
&lt;br /&gt;
==相关资料==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: 版本控制工具]]&lt;/div&gt;</summary>
		<author><name>Chenxing</name></author>	</entry>

	</feed>