在 Oracle 的開發工具 JDeveloper 11g/12c 中除了支援 SVN Server ( Subversion ) 外,也支援 git ,但測試了 git 目前在繁體中文的 Windows 平台上支援並不好,不過摸了幾天,還是記錄一下配置心得。

環境:

1. git server 1.7.x on Oracle Linux 6.5

2. gitweb 1.7 on apache 2.x

3. git clinet on windows 8 downloadGit-1.8.5.2-preview20131230.exe

 一、安裝 git server

git_package.png  

# rpm -qa | grep git
gitweb-1.7.1-3.el6_4.1.noarch
git-1.7.1-3.el6_4.1.x86_64

二、設定 git repository:project.git 在 /opt/git_root 目錄下

# pwd
/opt/git_root
# mkdir project.git
# cd project.git/
# git init --bare
Initialized empty Git repository in /opt/git_root/project.git/

註:可以修改 /opt/git_root/project.git/description 來說明此專案目的

# vi description
git Version Control Project

三、設定 repository:project.git 權限給 AD 的 Domain Users 有權限存放資料,參考:AD Account Login Linux Server (oracle linux 與 Windows AD 帳號認證整合)

# ls -al
total 40
drwxr-xr-x. 7 root root 4096 Jan 21 12:05 .
drwxr-xr-x. 3 root root 4096 Jan 21 11:35 ..
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 branches
-rw-r--r--. 1 root root  150 Jan 21 12:04 config
-rw-r--r--. 1 root root   73 Jan 21 11:35 description
-rw-r--r--. 1 root root   23 Jan 21 11:35 HEAD
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 hooks
drwxr-xr-x. 2 root root 4096 Jan 21 11:35 info
drwxr-xr-x. 7 root root 4096 Jan 21 11:49 objects
drwxr-xr-x. 4 root root 4096 Jan 21 11:35 refs

# chown -R root."WEI\Domain Users" refs/
# chown -R root."WEI\Domain Users" objects/
# chmod 775 -R refs/
# chmod 775 -R objects/

四、設定 gitweb:gitweb 預設安裝到了/var/www/git 下,其設定檔在 /etc/gitweb.conf ,另外,httpd 的設定檔為 /etc/httpd/conf.d/git.conf。

1) 修改 /etc/gitweb.conf

# vi /etc/gitweb.conf
our $projectroot = "/var/www/git";

2) 修改 /etc/httpd/conf.d/git.conf

# vi /etc/httpd/conf.d/git.conf
Alias /git /var/www/git
<Directory /var/www/git>
        Allow from all
        AllowOverride all
        Order allow,deny
        Options +ExecCGI
        AddHandler cgi-script .cgi
        DirectoryIndex gitweb.cgi
        SetEnv GITWEB_CONFIG /etc/gitweb.conf
        Dav On
        RewriteEngine Off
</Directory>

3) 重啟 apache server
# service httpd restart

4) 將 Git repository in /opt/git_root/project.git 連結到 /var/www/git 下

# ln -s /opt/git_root/project.git /var/www/git

5) 在 windows 平台用流覽器查看

gitweb_viewProject.png  
 六、測試

1) 在 windows 平台上安裝 Git-1.8.5.2-preview20131230.exe ,並將目錄 C:\Program Files (x86)\Git\cmd 加入 Windows 環境變數的 PATH  中

2) 在 windows 平台上將 Linux 主機上 git repository:project.git  clone 到 D:\git_repo 目錄下,並設定 D:\git_repo\project.git 資料夾為 UTF-8 編碼

D:\git_repo>git clone polin.wei@oradb12clinux:/opt/git_root/project.git
Cloning into 'project'...
polin.wei@oradb12clinux's password:
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

設定 D:\git_repo 目錄編碼為 utf-8:
    在 D:\git_repo\project.git 資料夾上,以滑鼠右鍵點選 Git Gui。
    按「Edit」,再點選「Option」。
    將 Global (All Repositories) 的「Default File Contents Encoding」改變為「utf-8」後,按「Save」。

3) 建立一份文字檔 readme.txt,內容為 "這是第一份文件"

D:\git_repo>cd project
D:\git_repo\project>notepad readme.txt
D:\git_repo\project>type readme.txt
這是第一份文件

4) commint 文件內容

D:\git_repo\project>git commit (這說明應該是:git 測試,但它變成了 git 晴)

git_vim_windows_commit.png  
[master (root-commit) 9ccc88e] git 晴
 1 file changed, 1 insertion(+)
 create mode 100644 readme.txt

Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as L
ucida Console!

5) 將文件上載到 git server on linux

D:\git_repo\project>git push origin master
polin.wei@oradb12clinux's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To polin.wei@oradb12clinux:/opt/git_root/project.git
 * [new branch]      master -> master

6) 使用 git gui 工具上傳,操作順序為:
  a. Rescan 查看有沒有文件被修改
  b. Stage Changed 設定文件內容為已被修改
  c. Commit 文件內容確認
  d. Push 到 Linux 主機上 git repository:project.git

git_gui_modify.png  

7) 再一次在 windows 平台用流覽器查看

gitweb_view_summary.png  

 

參考:

http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server

http://blog.xuite.net/yctseng/notes/35220134-gitweb

http://phpbb-tw.net/phpbb/viewtopic.php?t=53959

http://www.linuxso.com/linuxrumen/40000.html

http://www.linuxso.com/linuxrumen/40005.html

arrow
arrow
    全站熱搜

    MIS 發表在 痞客邦 留言(0) 人氣()