1. 程式人生 > >搭建輕量級git server和git web UI

搭建輕量級git server和git web UI

背景

如果你用ECS來管理日常程式碼,一定會有這樣一個過程:

step 1:

git clone user@domain.com:/my/git/repo/dir

step 2:

git clone http://domain.com/my-repo.git

step 3:

大部分人,停止在了第一步,因為第二步、第三步,還挺麻煩。特別是第二步。

週末再次(大約1年前已經摺騰過一次,惜敗)嘗試安裝gitlab-ce (community-edition),再次,惜敗!於是我決定放棄 gitlab,開闢新大陸。

工具

  • GitPHP

    線上瀏覽原始碼和 git 提交記錄的工具。基於PHP編寫,很輕量,無需資料庫,許可權控制功能相當強大。

  • Git-Lighttp

    以 http 的形式對外提供 git clone push 服務。基於Rudy編寫,無需資料庫。厭倦了基於 ssh 服務提交程式碼的話,不妨一試。

兩個工具都很靠譜,安裝文件比較缺乏,需要動用你的鑽研精神哦。下面就重點介紹一下。

安裝配置

安裝很簡單,直接從 git clone 即可。

GitPHP 和 Git-Lighttp 都支援許可權控制,下面重點說明。

GitPHP 配置

GitPHP的配置(包括許可權控制)都在原始碼的 config 目錄下

[[email protected] config]# tree
.
|-- gitphp.conf
.php |-- projects.conf.php `-- users.conf.php

核心配置包括:

gitphp.conf.php
---
// 注意:php 必須具有對 git 倉庫目錄的訪問許可權
$gitphp_conf['projectroot'] = './your/git/repo/dir';


projects.conf.php
---
可以不動


projects.conf.php
---
$gitphp_users = array(
  array(
    'username' => 'ray',
    'password' => 'woshidachunlv'
), array( 'username' => 'jack', 'password' => 'iloverose' ), array( 'username' => 'rose', 'password' => 'youjumpijump' ) );

使用者名稱密碼配置好後,去每一個 git 資料倉庫的 .git/config 檔案裡面增加專案 (project) 級別的許可權控制。例如 vue.git 專案中,給 ray 增加可讀的許可權:

[[email protected] vue.git]# pwd
/web/domain.com/git/repo/vue.git/

[[email protected] vue.git]# cat config
[core]
  repositoryformatversion = 0
  filemode = true
  bare = true
[gitphp]
  category = Vue
  description = Vue
  owner = Evan You
  cloneurl = http://git.domain.com:4096/vue.git
  pushurl = http://git.domain.com:4096/vue.git
  bugpattern = "/#([0-9]+)/"
  bugurl = http://bug.domain.com/projects/gitphp/issues/${1}
  compat = false
  website = http://www.domain.com/
  allowedusers = ray

不配置 [gitphp] 的話,預設對所有人可見。

Git-Lighttp 的許可權控制

它依賴 htpasswd 檔案來做許可權控制。執行 htpasswd 命令能夠新增使用者,將結果放到 repo 根目錄的 htpasswd 檔案裡。下面是我的配置:

[[email protected] repo]# pwd
/web/domain.com/git/repo
# 這是我的資料倉庫位置

[[email protected] repo]# tree -L 1
.
|-- htpasswd
|-- gitphp.git
|-- vue.git
`-- vue-cli.git

[[email protected] repo]# cat htpasswd
ray:.za9933xxooB6

ray 就是我的使用者名稱,在 clone 和 push 的時候會用到。

例如,在我的 Mac 上使用 git 倉庫:


[[email protected] repo]#  git clone http://git.domain.com:4096/vue.git
Cloning into 'vue'...
Username for 'http://git.domain.com:4096': ray
Password for 'http://[email protected]:4096':
remote: Counting objects: 16183, done.
remote: Compressing objects: 100% (4274/4274), done.
remote: Total 16183 (delta 11817), reused 16172 (delta 11811)
Receiving objects: 100% (16183/16183), 5.33 MiB | 487.00 KiB/s, done.
Resolving deltas: 100% (11817/11817), done.
Checking connectivity... done.

總結

其實,還是 gitlab 省事,無奈 gitlab-ce 就不是誠心給人用,太難安裝了。 如果你有錢,專門買個預裝了 Gitlab 的 ECS,忒方便。 或者買個 預裝 Ubuntu 的 ECS, 然後安裝一個 Docker,最後搞個 Gitlab 的 Docker 釋出包裝一下就行了。

自己裝一個 Git Server 是長久以來的打算,終於完成了,之後的程式碼管理可以更規範一些,不錯不錯。

相關推薦

搭建輕量級git servergit web UI

背景 如果你用ECS來管理日常程式碼,一定會有這樣一個過程: step 1: git clone [email protected]:/my/git/repo/dir step 2: git clone http://domain.com/my-rep

Spring-cloud 微服務架構搭建 02 - config-server 整合git動態重新整理配置及安全管理

文章目錄 1. sping-cloud config簡介 2. sping-cloud config 服務特點 3. Config-Server 服務端搭建 4. Config-Client 端搭建 5. 動

利用git bashgit gui向git遠程倉庫提交文件

article bash 命令 rep 路徑 stage chang osi .html 1、首先在該文件夾下git init 2、然後在github下面創建一個新倉庫去存儲你的代碼 3、然後利用add添加遠程倉庫 4、然後點擊stage changed 5、最後點擊長傳

git fetch git pull 的差別

ria 版本 trac con etc 更新 _id track pull Git中從遠程的分支獲取最新的版本號到本地有這樣2個命令: 1. git fetch:相當於是從遠程獲取最新版本號到本地,不會自己主動merge git fetch or

git merge git merge --no-ff

title ack lines rip print () pri addclass int 依據這張圖片能夠看出 git merge –no-ff 能夠保存你之前的分支歷史。能夠更好的查看 merge歷史。以及branch 狀態。 git m

git:Git fetchgit pull的區別, 解決Git報錯:error: You have not concluded your merge (MERGE_HEAD exists).

pre ret mas -h ruby error you origin 分支 Git fetch和git pull的區別, 解決Git報錯:error: You have not concluded your merge (MERGE_HEAD exists). 解決

git addgit commit

stage mod com 指定 for 命令 現在 ssa -m git命令使用:提交前可指定要提交哪些文件,然後使用git commit來提交 樣例: git status 輸出: Changes to be committed: modified: ap

git 命令 git stash git stash pop

今天 merge 報錯 版本 pull 一個 一次 後來 更新 今天好心累 居然把我寫的東西都沒了 本地和遠程的版本差別太大 於是我想更新一下 更新的時候報錯了 於是我按照老師的來 之前忘記了他怎麽操作的 只記得有 git stash -> git merge -&

使用plumbing命令來深入理解git addgit commit的工作原理

clean 結果 write 文件的 repos 倉庫 head 根據 acc 前言: plumbing命令 和 porcelain命令 git中的命令分為plumbing命令和porcelain命令: porcelain命令就是我們常用的git add,git comm

伺服器上安裝git倉庫git本地

 原文來自:    https://blog.csdn.net/li_wen01/article/details/52411543 git伺服器搭建,本來是一件簡單的事情,但是因為網上的很多教程都不詳細,造成的後果就是搭建出來的伺服器很多的許可權的問題,於

git的常用指令(二) git add -A 、git add . git add -u

git add . :他會監控工作區的狀態樹,使用它會把工作時的所有變化提交到暫存區,包括檔案內容修改(modified)以及新檔案(new),但不包括被刪除的檔案。 git add -u :他僅監控已經被add的檔案(即tracked file),他會將被修改的檔案提交到暫存區。add -u 不會提交新檔

git clone、git pullgit fetch的用法及區別

更新 服務器 指定 保存 今天 文章 git fetch origin 收藏 聲明:碼字不易,轉載請註明出處,歡迎文章下方討論交流。 最近在一個學習小組裏學習AI的課程,我們所有的學習資料和homework都放在gitlab上。今天一個小隊友從gitlab上load倉庫的時

git rebase git merge 的區別

git rebase 和 git merge 的區別  AlvinStar 關注 2016.07.31 17:32* 字數 760 閱讀 14895評論 6喜歡 28讚賞 1 Description git rebase 和 git merge

git revertgit reset的區別

原文:http://blog.csdn.net/koffuxu/article/details/6731876 git revert  是生成一個新的提交來撤銷某次提交,此次提交之前的commit都會被保留 git reset  是

git init git --bare init的區別

git init  和 git --bare init 的區別在於: git init 帶工作區 git --bare init  是不帶工作區的,只有版本庫,想要看git裡面的內容只能通過git clone address的方式克隆出來 而我們在初始化遠端倉庫時最好使

git rebasegit cherry-pick衝突解決方法

手動編輯衝突檔案,手動刪除或者保留衝突的程式碼; 對於“both added”、“both deleted”、“both modified”等型別的衝突,若想完整地保留某一方的修改可以執行git checkout --ours(或者–theirs) <檔名>來選擇想要保留的版本。需要注意的是由於

Git fetchgit pull的區別

Git中從遠端的分支獲取最新的版本到本地有這樣2個命令:1. git fetch:相當於是從遠端獲取最新版本到本地,不會自動mergegit fetch origin mastergit log -p master..origin/mastergit merge origin/master    以上命令的含

git rebase git merge區別

使用下面的關係區別這兩個操作: git pull = git fetch + git merge git pull --rebase = git fetch + git rebase 現在來看看git merge和git rebase的區別。 假設有3次提交A,B,C。 在遠端分支

Git知識總覽(一) 從 git clone git status 談起

本篇部落格是整理git相關知識的第一篇,因為之前一直是用SourceTree對Git的命令列操作用的不是特別熟,於是乎過了一遍ProGit(連結:)。本篇部落格以及後邊的將要發的幾篇部落格是對之前看ProGit時的筆記的整理。當然在整理時,根據具體示例來梳理了一下知識點,和ProGit上的講解順序有些區別。本

git rebase git fetch 區別

dev分支狀態如下: test分支狀態如下: 使git merge test之後: 可見dev分支有了一次新的提交併且test分支之後的提交都當作當前分支的提交依次在log中顯示。對test分支的log木有影響。 使用git reset –hard HE