在Ubuntu/Fedora/CentOS中安装Gitblit

huhongfei 2015-03-25

Git是一款注重速度、数据完整性、分布式支持和非线性工作流的分布式版本控制工具。Git最初由Linus Torvalds在2005年为Linux内核开发而设计,如今已经成为被广泛接受的版本控制系统。

和其他大多数分布式版本控制系统比起来,不像大多数客户端-服务端的系统,每个Git工作目录是一个完整的仓库,带有完整的历史记录和完整的版本跟踪能力,不需要依赖网络或者中心服务器。像Linux内核一样,Git也是在GPLv2许可证下分发的自由软件。

本篇教程我会演示如何安装 gitlit 服务器。gitlit的最新稳定版是1.6.2。Gitblit是一款开源、纯Java开发的用于管理、浏览和提供Git仓库服务的软件。它被设计成一款为希望托管中心仓库的小型工作组服务的工具。

  1. <span class="pln">mkdir </span><span class="pun">-</span><span class="pln">p </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">gitblit</span><span class="pun">;</span><span class="pln"> cd </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">gitblit</span><span class="pun">;</span><span class="pln"> wget http</span><span class="pun">:</span><span class="com">//dl.bintray.com/gitblit/releases/gitblit-1.6.2.tar.gz</span>

 

列出解压后目录内容:

  1. <span class="pln">root@vps124229 </span><span class="pun">[</span><span class="str">/opt/</span><span class="pln">gitblit</span><span class="pun">]#</span><span class="pln"> ls</span>
  2. <span class="pun">./</span><span class="pln"> docs</span><span class="pun">/</span><span class="pln"> gitblit</span><span class="pun">-</span><span class="pln">stop</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> LICENSE service</span><span class="pun">-</span><span class="pln">Ubuntu</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span>
  3. <span class="pun">../</span><span class="pln"> ext</span><span class="pun">/</span><span class="pln"> install</span><span class="pun">-</span><span class="pln">service</span><span class="pun">-</span><span class="pln">CentOS</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> migrate</span><span class="pun">-</span><span class="pln">tickets</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span>
  4. <span class="pln">add</span><span class="pun">-</span><span class="pln">indexed</span><span class="pun">-</span><span class="pln">branch</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> gitblit</span><span class="pun">-</span><span class="lit">1.6</span><span class="pun">.</span><span class="lit">2.tar</span><span class="pun">.</span><span class="pln">gz install</span><span class="pun">-</span><span class="pln">service</span><span class="pun">-</span><span class="pln">Fedora</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> NOTICE</span>
  5. <span class="pln">authority</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> gitblit</span><span class="pun">.</span><span class="pln">jar install</span><span class="pun">-</span><span class="pln">service</span><span class="pun">-</span><span class="pln">ubuntu</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> reindex</span><span class="pun">-</span><span class="pln">tickets</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span>
  6. <span class="pln">data</span><span class="pun">/</span><span class="pln"> gitblit</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> java</span><span class="pun">-</span><span class="pln">proxy</span><span class="pun">-</span><span class="pln">config</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span><span class="pln"> service</span><span class="pun">-</span><span class="pln">centos</span><span class="pun">.</span><span class="pln">sh</span><span class="pun">*</span>

默认配置文件在data/gitblit.properties,你可以根据需要自己修改。

 

启动gitlit服务:

通过service命令:

  1. <span class="pln">root@vps124229 </span><span class="pun">[</span><span class="str">/opt/</span><span class="pln">gitblit</span><span class="pun">]#</span><span class="pln"> cp service</span><span class="pun">-</span><span class="pln">centos</span><span class="pun">.</span><span class="pln">sh </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">init</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">gitblit</span>
  2. <span class="pln">root@vps124229 </span><span class="pun">[</span><span class="str">/opt/</span><span class="pln">gitblit</span><span class="pun">]#</span><span class="pln"> chkconfig </span><span class="pun">--</span><span class="pln">add gitblit</span>
  3. <span class="pln">root@vps124229 </span><span class="pun">[</span><span class="str">/opt/</span><span class="pln">gitblit</span><span class="pun">]#</span><span class="pln"> service gitblit start</span>
  4. <span class="typ">Starting</span><span class="pln"> gitblit server</span>
  5. <span class="pun">.</span>

手动启动:

  1. <span class="pln">root@vps124229 </span><span class="pun">[</span><span class="str">/opt/</span><span class="pln">gitblit</span><span class="pun">]#</span><span class="pln"> java </span><span class="pun">-</span><span class="pln">jar gitblit</span><span class="pun">.</span><span class="pln">jar </span><span class="pun">--</span><span class="pln">baseFolder data</span>
  2. <span class="lit">2015</span><span class="pun">-</span><span class="lit">01</span><span class="pun">-</span><span class="lit">10</span><span class="lit">09</span><span class="pun">:</span><span class="lit">16</span><span class="pun">:</span><span class="lit">53</span><span class="pun">[</span><span class="pln">INFO </span><span class="pun">]</span><span class="pun">*****************************************************************</span>
  3. <span class="lit">2015</span><span class="pun">-</span><span class="lit">01</span><span class="pun">-</span><span class="lit">10</span><span class="lit">09</span><span class="pun">:</span><span class="lit">16</span><span class="pun">:</span><span class="lit">53</span><span class="pun">[</span><span class="pln">INFO </span><span class="pun">]</span><span class="pln"> _____ _ _ _ _ _ _</span>
  4. <span class="lit">2015</span><span class="pun">-</span><span class="lit">01</span><span class="pun">-</span><span class="lit">10</span><span class="lit">09</span><span class="pun">:</span><span class="lit">16</span><span class="pun">:</span><span class="lit">53</span><span class="pun">[</span><span class="pln">INFO </span><span class="pun">]</span><span class="pun">|</span><span class="pln"> __ \(_</span><span class="pun">)|</span><span class="pun">|</span><span class="pun">|</span><span class="pun">|</span><span class="pun">|</span><span class="pun">|(</span><span class="pln">_</span><span class="pun">)|</span><span class="pun">|</span>
  5. <span class="lit">2015</span><span class="pun">-</span><span class="lit">01</span><span class="pun">-</span><span class="lit">10</span><span class="lit">09</span><span class="pun">:</span><span class="lit">16</span><span class="pun">:</span><span class="lit">53</span><span class="pun">[</span><span class="pln">INFO </span><span class="pun">]</span><span class="pun">|</span><span class="pun">|</span><span class="pln"> \/ _ </span><span class="pun">|</span><span class="pun">|</span><span class="pln">_ </span><span class="pun">|</span><span class="pun">|</span><span class="pln">__ </span><span class="pun">|</span><span class="pun">|</span><span class="pln"> _ </span><span class="pun">|</span><span class="pun">|</span><span class="pln">_</span>
  6. <span class="lit">2015</span><span class="pun">-</span><span class="lit">01</span><span class="pun">-</span><span class="lit">10</span><span class="lit">09</span><span class="pun">:</span><span class="lit">16</span><span class="pun">:</span><span class="lit">53</span><span class="pun">[</span><span class="pln">INFO </span><span class="pun">]</span><span class="pun">|</span><span class="pun">|</span><span class="pln"> __ </span><span class="pun">|</span><span class="pun">||</span><span class="pln"> __</span><span class="pun">||</span><span class="str">'_ \ | || || __|</span>
  7. <span class="str">2015-01-10 09:16:53 [INFO ] | |_\ \| || |_ | |_) || || || |_</span>
  8. <span class="str">2015-01-10 09:16:53 [INFO ] \____/|_| \__||_.__/ |_||_| \__|</span>
  9. <span class="str">2015-01-10 09:16:53 [INFO ] Gitblit v1.6.2</span>
  10. <span class="str">2015-01-10 09:16:53 [INFO ] </span>
  11. <span class="str">2015-01-10 09:16:53 [INFO ] *****************************************************************</span>
  12. <span class="str">2015-01-10 09:16:53 [INFO ] Running on Linux (3.8.13-xxxx-grs-ipv6-64-vps)</span>
  13. <span class="str">2015-01-10 09:16:53 [INFO ] Logging initialized @842ms</span>
  14. <span class="str">2015-01-10 09:16:54 [INFO ] Using JCE Unlimited Strength Jurisdiction Policy files</span>
  15. <span class="str">2015-01-10 09:16:54 [INFO ] Setting up HTTPS transport on port 8443</span>
  16. <span class="str">2015-01-10 09:16:54 [INFO ] certificate alias = localhost</span>
  17. <span class="str">2015-01-10 09:16:54 [INFO ] keyStorePath = /opt/gitblit/data/serverKeyStore.jks</span>
  18. <span class="str">2015-01-10 09:16:54 [INFO ] trustStorePath = /opt/gitblit/data/serverTrustStore.jks</span>
  19. <span class="str">2015-01-10 09:16:54 [INFO ] crlPath = /opt/gitblit/data/certs/caRevocationList.crl</span>
  20. <span class="str">2015-01-10 09:16:54 [INFO ] Shutdown Monitor listening on port 8081</span>
  21. <span class="str">2015-01-10 09:16:54 [INFO ] jetty-9.2.3.v20140905</span>
  22. <span class="str">2015-01-10 09:16:55 [INFO ] NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet</span>
  23. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  24. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IRuntimeManager]----</span>
  25. <span class="str">2015-01-10 09:16:55 [INFO ] Basefolder : /opt/gitblit/data</span>
  26. <span class="str">2015-01-10 09:16:55 [INFO ] Settings : /opt/gitblit/data/gitblit.properties</span>
  27. <span class="str">2015-01-10 09:16:55 [INFO ] JVM timezone: America/Montreal (EST -0500)</span>
  28. <span class="str">2015-01-10 09:16:55 [INFO ] App timezone: America/Montreal (EST -0500)</span>
  29. <span class="str">2015-01-10 09:16:55 [INFO ] JVM locale : en_US</span>
  30. <span class="str">2015-01-10 09:16:55 [INFO ] App locale : <client></span>
  31. <span class="str">2015-01-10 09:16:55 [INFO ] PF4J runtime mode is '</span><span class="pln">deployment</span><span class="str">'</span>
  32. <span class="str">2015-01-10 09:16:55 [INFO ] Enabled plugins: []</span>
  33. <span class="str">2015-01-10 09:16:55 [INFO ] Disabled plugins: []</span>
  34. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  35. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.INotificationManager]----</span>
  36. <span class="str">2015-01-10 09:16:55 [WARN ] Mail service disabled.</span>
  37. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  38. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IUserManager]----</span>
  39. <span class="str">2015-01-10 09:16:55 [INFO ] ConfigUserService(/opt/gitblit/data/users.conf)</span>
  40. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  41. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IAuthenticationManager]----</span>
  42. <span class="str">2015-01-10 09:16:55 [INFO ] External authentication disabled.</span>
  43. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  44. <span class="str">2015-01-10 09:16:55 [INFO ] ---- [com.gitblit.transport.ssh.IPublicKeyManager]----</span>
  45. <span class="str">2015-01-10 09:16:55 [INFO ] FileKeyManager (/opt/gitblit/data/ssh)</span>
  46. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  47. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IRepositoryManager]----</span>
  48. <span class="str">2015-01-10 09:16:55 [INFO ] Repositories folder : /opt/gitblit/data/git</span>
  49. <span class="str">2015-01-10 09:16:55 [INFO ] Identifying repositories...</span>
  50. <span class="str">2015-01-10 09:16:55 [INFO ] 0 repositories identified with calculated folder sizes in 11 msecs</span>
  51. <span class="str">2015-01-10 09:16:55 [INFO ] Lucene will process indexed branches every 2 minutes.</span>
  52. <span class="str">2015-01-10 09:16:55 [INFO ] Garbage Collector (GC) is disabled.</span>
  53. <span class="str">2015-01-10 09:16:55 [INFO ] Mirror service is disabled.</span>
  54. <span class="str">2015-01-10 09:16:55 [INFO ] Alias UTF-9 & UTF-18 encodings as UTF-8 in JGit</span>
  55. <span class="str">2015-01-10 09:16:55 [INFO ] Preparing 14 day commit cache. please wait...</span>
  56. <span class="str">2015-01-10 09:16:55 [INFO ] 0 repositories identified with calculated folder sizes in 0 msecs</span>
  57. <span class="str">2015-01-10 09:16:55 [INFO ] built 14 day commit cache of 0 commits across 0 repositories in 2 msecs</span>
  58. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  59. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IProjectManager]----</span>
  60. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  61. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IFederationManager]----</span>
  62. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  63. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IGitblit]----</span>
  64. <span class="str">2015-01-10 09:16:55 [INFO ] Starting services manager...</span>
  65. <span class="str">2015-01-10 09:16:55 [INFO ] Federation passphrase is blank! This server can not be PULLED from.</span>
  66. <span class="str">2015-01-10 09:16:55 [INFO ] Fanout PubSub service is disabled.</span>
  67. <span class="str">2015-01-10 09:16:55 [INFO ] Git Daemon is listening on 0.0.0.0:9418</span>
  68. <span class="str">2015-01-10 09:16:55 [INFO ] SSH Daemon (NIO2) is listening on 0.0.0.0:29418</span>
  69. <span class="str">2015-01-10 09:16:55 [WARN ] No ticket service configured.</span>
  70. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  71. <span class="str">2015-01-10 09:16:55 [INFO ] ----[com.gitblit.manager.IPluginManager]----</span>
  72. <span class="str">2015-01-10 09:16:55 [INFO ] No plugins</span>
  73. <span class="str">2015-01-10 09:16:55 [INFO ] </span>
  74. <span class="str">2015-01-10 09:16:55 [INFO ] All managers started.</span>

打开浏览器,依据你的配置进入http://localhost:8080 或者 https://localhost:8443。 输入默认的管理员授权:admin / admin 并点击Login 按钮

在Ubuntu/Fedora/CentOS中安装Gitblit

 

添加用户:

在Ubuntu/Fedora/CentOS中安装Gitblit

 

添加仓库:

在Ubuntu/Fedora/CentOS中安装Gitblit

 

用命令行创建新的仓库:

  1. <span class="pln">touch README</span><span class="pun">.</span><span class="pln">md</span>
  2. <span class="pln">git init</span>
  3. <span class="pln">git add README</span><span class="pun">.</span><span class="pln">md</span>
  4. <span class="pln">git commit </span><span class="pun">-</span><span class="pln">m </span><span class="str">"first commit"</span>
  5. <span class="pln">git remote add origin ssh</span><span class="pun">:</span><span class="com">//[email protected]:29418/Programming.git</span>
  6. <span class="pln">git push </span><span class="pun">-</span><span class="pln">u origin master</span>

 

从命令行推送已有的仓库:

  1. <span class="pln">git remote add origin ssh</span><span class="pun">:</span><span class="com">//[email protected]:29418/Programming.git</span>
  2. <span class="pln">git push </span><span class="pun">-</span><span class="pln">u origin master</span>

完成!

GitHub 教程系列文章: 

Git 的详细介绍:请点这里
Git 的下载地址:请点这里

相关推荐