1. 安裝git, gitweb, spawn-fcgijavascript
a)css
yum install -y git gitweb spawn-fcgi fcgi-devel fcgihtml
b)編譯安裝java
error)nginx
BEGIN failed--compilation aborted at Makefile.PL line 3.git
make[1]: *** [perl.mak] Error 2web
make: *** [perl/perl.mak] Error 2shell
fix ) yum install perl-ExtUtils-MakeMakerapache
error) vim
/bin/sh: msgfmt: command not found
fix) yum install gettext-devel
2. 安裝fcgiwrap
http://my.oschina.net/Kilar/blog/543081
3. 編輯/etc/gitweb.conf
$projectroot = "/data/git/repo" $git_temp = "/tmp"; $home_text = "indextext.html"; #$projects_list = "/home/git/projects.list"; @stylesheets = ("static/gitweb.css"); $javascript = "static/gitweb.js"; $favicon = "static/eab-favicon.png"; @diff_opts = (); $feature{pathinfo}{default} = [1];
4. 修改/etc/sysconfig/spawn-fcgi
FCGI_SOCKET=/var/run/fcgiwrap.socket FCGI_PROGRAM=/usr/local/bin/fcgiwrap FCGI_USER=nginx FCGI_GROUP=nginx FCGI_EXTRA_OPTIONS="-M 0700" OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"
5. 添加nginx的git配置
mkdir -p /usr/local/nginx/conf/vhost
vim /usr/local/nginx/conf/vhost
server { listen 80; server_name git.ee; # 用戶認證,passwd使用htpasswd生成,和apache同樣,htpasswd能夠從soft.vpser.net/lnmp/ext/htpasswd.sh獲取 error_log /data/user/log/nginx/git.error.log; access_log /data/user/log/nginx/git.access.log; client_max_body_size 4000m; client_body_buffer_size 8m; auth_basic "Git Authorize"; auth_basic_user_file /home/data/passwd; # 訪問地址爲http://your_hsotname/xxxx.git location ~ (/.*) { # disalbe gzip gzip off; # fastcgi sockt fastcgi_pass unix:/var/run/fcgiwrap.socket; # fastcgi parameters include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; fastcgi_param DOCUMENT_ROOT /usr/libexec/git-core/; fastcgi_param SCRIPT_NAME git-http-backend; fastcgi_param GIT_HTTP_EXPORT_ALL ""; # git的工做目錄 fastcgi_param GIT_PROJECT_ROOT /data/git/repo; fastcgi_param PATH_INFO $1; fastcgi_param REMOTE_USER $remote_user; } }
6. git push拒絕時 ([remote rejected] master )
這是因爲git默認拒絕了push操做,須要進行設置,修改.git/config文件後面添加以下代碼:
[receive]
denyCurrentBranch = ignore
沒法查看push後的git中文件的緣由與解決方法
在初始化遠程倉庫時最好使用 git --bare init 而不要使用:git init
若是使用了git init初始化,則遠程倉庫的目錄下,也包含work tree,當本地倉庫向遠程倉庫push時, 若是遠程倉庫正在push的分支上(若是當時不在push的分支,就沒有問題), 那麼push後的結果不會反應在work tree上, 也即在遠程倉庫的目錄下對應的文件仍是以前的內容。
解決方法:
必須得使用命令 git reset --hard 才能看到push後的內容.
7.automate補全
若是你用的是 Bash shell,能夠try看 Git 提供的automate補全腳本。下載 Git 的源代碼,進入 contrib/completion
目錄,會看到一個git-completion.bash
文件。將此文件複製到yourself用戶主目錄中(譯註:按照下面的示例,還應更名加上點:cp git-completion.bash ~/.git-completion.bash
),並把下面一行內容添加到你的 .bashrc
文件中:
source ~/.git-completion.bash
也能夠爲系統上全部用戶都設置默認使用此腳本。Mac 上將此腳本複製到 /opt/local/etc/bash_completion.d
目錄中,Linux 上則複製到/etc/bash_completion.d/
目錄中。這兩處目錄中的腳本,都會在 Bash 啓動時automate加載。
參考
http://blog.csdn.net/yuanchao99/article/details/39052937
http://www.cnblogs.com/shmmah/p/5016735.html
http://blog.csdn.net/n289950578/article/details/24245223
http://blog.jobbole.com/26131/