顯示具有 專案 標籤的文章。 顯示所有文章
顯示具有 專案 標籤的文章。 顯示所有文章

2015年8月11日 星期二

(再度) 如何在 Synology NAS 設置 GIT 伺服器 (新版)

2013 年曾發表兩篇文章, 是多年前的老機器 DS107 的紀錄, 這台機器的 DSM 已經停止更新, 當時他是無法透過 DSM 安裝 GIT 套件, 所以只能手動(ipkg)安裝, 最近購入 DS214 發現新的 DSM 上已經有套件可以直接安裝, 如果你的 DSM 有支援線上安裝 GIT Server 可參考本文...

===================================================

NOTE: 這是我的私人記錄, 不是教學!

環境:

1. Synology DS214Play+ DSM 5.2-5592 版
2. 有實體 IP 11.22.33.44 (此為亂寫)

How to setup a GIT Server on a Synology NAS
-------------------------------------------
 
1. 先啟動 SSH 功能
   DSM-> 控制台 -> 進階模式 -> 終端機 & SNMP -> [v] 啟動 SSH 功能

   P.S. 安全起見建議你自訂連接埠!

2. 安裝 Git Server 套件
   DSM-> 套件中心 -> 收尋 "git" -> 找到 [Git Server] -> 點 [安裝套件]

   P.S. 要等待一下下安裝完成...

3. 啟動 Git Server 套件
   DSM -> 套件中心 -> 已安裝 -> 找到 [Git Server], 點選 -> 點 [動作] -> 啟動

4. 建立 git 庫(repository) 的位置, 假定 "git-repo"
   DSM -> 控制台 -> 共用資料夾 -> [新增] -> 名稱 "git-repo"

   P.S. 以上名稱可以自訂.

5. 建立 git server 使用者, 假定 "git.user", "blabla"...
   DSM -> 控制台 -> 使用者帳號 -> [新增] -> 名稱 "git.user", 密碼 "xxx" ->
   指定群組, 勾 "Users" (*) -> 在 "指派共用資料夾權限" 頁面, 在 "git-repo" 的 "可讀寫"
   打勾

   P.S. (*)可以把全部使用 git server 的使用者, 放在一個專用的群組.
   P.S. 以上名稱可以自訂.

6. 設置 Git Server 使用者
   DSM -> 主選單 -> Git Server -> "git.user" 的 "允許存取" 打勾

7. 建立 git 庫(repository), 假定 "test"

   [方法1] Only for Windows (or Mac?)

      前提:
        1. NAS 能位於 PC 相同的區域網域(**), PC 能連線 NAS 為網路磁碟(或資料夾)

           P.S: (**)實際上我的 NAS 都是放在區(內)網 192.168.0.x, 由 router 映射一個
                外部 ip:port 給 NAS 需要開放的服務, like
                11.22.33.44:1234 -> 192.168.0.x:22 (your SSH port in NAS)

        2. PC 有安裝 TortoiseGit, 或其他 Git clients.

      步驟:
        1. 啟動 NAS 的 Windows 檔案服務
              DSM -> 控制台 -> 檔案服務 -> [Windows 檔案服務] -> 啟動, 注意下面有寫 PC
              檔案總管如何存取...預設為 \\Diskstation

        2. PC -> 檔案總管 -> 選單, 連線網路磁碟機 -> 指定磁碟機代號, 資料夾輸入
           \\Diskstation\git-repo -> 輸入 DSM 的(管理員或 git.user)的登入名字與密碼

           或

           PC -> 檔案總管 -> 頁籤, 電腦 -> 滑鼠在 [網路位置] 上按右鍵選單 -> 新增一個網路
           位置 ->選擇自訂網路位置 -> 輸入 \\RICHSTATION\git-repo -> ...

        3. 如果你已經是 TortoiseGit 的能力者, 剩下就簡單並直覺了...
              a) 在 NAS 上新建 GIT 專案庫:
                 直接打開網路資料夾 git-repo -> 裡面新建一個資料夾 "test" ->
                 滑鼠在 "test" 資料夾上按右鍵選單 -> Git Create repository here... ->
                 勾 'Make It Bare' (***) -> OK.

         P.S: (***)這裡還蠻重要的, 因為是遠端庫, 不在庫目錄上直接工作, 不勾會導致每次本
                地 push 遠端時都發一個警告...

              b) 轉移既有(或備份)的 GIT 專案庫到 NAS:
                 不用多說了把既有的 GIT 專案庫(bared)複製到網路資料夾 git-repo 裡面!

   [方法2] SSH 登入 NAS

      步驟:
        1. PC 執行 SSH client(!), Host Name: 11.22.33.44, Port: 22 (或自訂過)
            P.S. (!) 我是用 PuTTY

        2. Login as: admin
            Password: (NAS 網頁管理頁面(admin)用的密碼)

        NOTE: 這裡登入名字建議不要用 'root', root 登入後若不切換帳號, 可能會導致後面建
                  test 資料夾權限只限 root 用戶可存取, 此時還要用 chmod 修改...
        NOTE: 如果密碼沒錯卻拒絕登入, 可以檢查:
 
                1. ip:port 是否正確, 路由 ip(router):port -> NAS:port 都正確? 
                2. 是否被 router(firewall) 封鎖 IP or port? 
                3. 是否被 NAS 封鎖 IP or port?
                4. NAS 的 SSH 服務已經已啟動?

        3. 接下來操作 shell commands
      Diskstation> cd /volume1/git-repo/
      Diskstation> pwd 

            (確認一下目前目錄為上面嗎)
            /volume1/git-repo
      Diskstation> mkdir test

            (建立新的資料夾擺放 test 專案的 Git 庫)
      Diskstation> ls -l
            (確認一下目錄的權限)
      ...
      drwxrwxrwx  7 admin users  4096 Aug 12 15:26 test
       ^^^^^^^^^          ^^^^^ 

       123456789 
       -> 123:admin 可讀寫執行, 456:users 可寫執行, 789:其他人也可
      NOTE: 權限不對, 會導致 git.user 在本地無法存取 /volume1/git-repo/test, 此時可
                用 chmod 修改, 或直接換用 git.user 身份建立資料夾... 
                參見 如何在 (老) Synology NAS 設置 GIT 伺服器 (2/2)

      Diskstation> cd test
      Diskstation> pwd

            (確認一下目前目錄為上面嗎)
            /volume1/git-repo/test
      Diskstation> git --bare init

            (建立初始 git 空庫)
            Initialized empty Git repository in /volume1/git-repo/test/


8. Clone Git 庫
   以步驟 7 的 test Git 庫, 其遠端的存取位置(URL)為

   ssh://git.user@11.22.33.44:22/volume1/git-repo/test

   NOTE:  1. git.user 為步驟 5 的建立的 git 使用者名字. 請替換為你的名字.
   NOTE:  2. :22 為預設 SSH 連接埠, 或是你有自訂其他的數值...

   操作 Git client 的 clone, 連線後會問 git.user 的密碼, 輸入後, 如正確無誤, 就開始複製
   檔案到本地, Git 的使用方法此處不多說了...

參考: Synology Git 套件說明

Q1: 每次本地操作 remote git 時都會出現 "Could not chdir to home directory /var/services/homes/git.user: No such file or directory"?

A1: 這是因為 DSM 操作新增 git.user 時並沒有建立其家目錄, 這只是警告不妨礙 Git 操作, 如果不愛, 可以用 SSH 登入 NAS, 操作 shell 指令方式, 重新指定 git.user 的家目錄, 參見
如何在 (老) Synology NAS 設置 GIT 伺服器 (2/2) 中, 步驟 15 有說明修改(改家目錄, shell 應該不用改).

2013年4月8日 星期一

如何轉移 SVN 專案為 GIT 管控

我有一個既有的專案由 SVN 管控(遠端 server 1), 因為(*)我想要以後改用 GIT 管控(遠端 server 2), 但仍希望在 GIT 裡面還能看到舊有 SVN 版本的歷史紀錄.

NOTE: (*) 任何理由, 我猜大部分是因為有某人堅持 ^^


其實這個的需求跟之前我發表的 SVN 與 GIT 協同工作是同一回事, 只是改另外一種 "不回頭" 的說法, 把原有的紀錄搬過來後, 原有的 SVN 庫不要了, 而且會以為一開始就是 GIT 管控...

所以不再詳細寫下步驟, 快速的紀錄一下重點 

Converting a Subversion repository to Git
-----------------------------------------

by TortoiseGit and TortoiseSVN

1. 原有的 SVN 庫, 必須要能用 URL 方式 like svn://xx.xx.xx.xx/oo 
   或 http://...方式存取, 而不是 file:///x:/xx/oo 這種檔案路徑方式, 
   如果 SVN 庫是放在本電腦用 file:// 方式, 請設置正確的 svn service 並
   啟動, 改用 SVN://...

2. 建立一個新的 folder A, 操作 TortoiseGit clone, URL 填 SVN://..., 
   下面 'From SVN Repository' 勾選, 把整個 SVN clone 至這個 folder,
   此時 folder A 為 GIT 管控, 但還與 SVN 庫連結著.

   這個(folder A as GIT)可以查到全部的 SVN 歷史紀錄

3. a) GIT 庫仍在本機: 建立另一個新的 folder B, 操作 TortoiseGit 在這裡

      建立一個新的 bare git 庫
   b) GIT 庫放在他機: 遠端放 Git 庫的 server, 建立好一個新的 bare git 庫

   此 git 庫就是以後你要送交的地方(remote).

4. 在 folder A 處開啟 TortoiseGit, settings -> Git -> Remote 新增
   一個 remote 為 step 3 的位置.

5. 把 folder A 全部的文件, push 至 step 4 新增 remote 的位置.

6. (**)建立另一個新的 folder C, 操作 TortoiseGit clone 自 step 4 的
   位置, 此 folder C 就是你最後要的工作路徑.

   NOTE: (**) 我後來想到, 如果直接在 folder A 裡的 remote 設置
          (as step 4 處), 把 original 的 SVN 的位置刪去, 不就好了?
          那就不需要在弄一個 folder C, 需再測試看看此法, 但建立
          folder C 新的 clone 也有順便測試以別人角色抓此 GIT 庫的好處.

7. 砍掉 folder A, 砍掉 SVN 庫....

8. 以後就在 folder C 工作, 可以提交本地端也可以 push 至遠端(***)...

   P.S. (***) 對啦, 堅持的人總是說這個理由啦...:)

參考: http://john.albin.net/git/convert-subversion-to-git

P.S. 上面參考是用 git 指令操作, 感覺很複雜, 也許我的方法缺陷沒測到, 先這樣以後再說...


如何在 (老) Synology NAS 設置 GIT 伺服器 (2/2)

NOTE: (08/11/2015) 本文是多年前的老機器 DS107 的紀錄, 這台機器的 DSM 已經停止更新, 當時他是無法透過 DSM 安裝 GIT 套件, 所以只能手動(ipkg)安裝, 最近購入 DS214 發現新的 DSM 上已經有套件可以直接安裝, 如果你的 DSM 有支援線上安裝 GIT Server 請不要再看本文, 參見 Synology Git 套件說明 或新版的 如何在 Synology NAS 設置 GIT 伺服器 (新版) ^^

========================================
接...如何在 Synology NAS 設置 GIT 伺服器 (1/2)

以上軟體都安裝好了, 接著設置一個共用的 SSH 帳號(*)能在 GIT 專案裡使用...

NOTE: (*) 此採取一個共用的 SSH 帳號登入而已, 但各自能以 GIT client 端設置自己的名字 commit.

14. 在 NAS 建立新使用者及共享目錄
 
   a) 進入 NAS WEB 管理頁面
   b) 控制台 -> 共用資料夾, "新增" 一個新共用資料夾, 名稱 "git-repo"
   c) 控制台 -> 使用者帳號, "新增" 一個新使用者, 名稱 "git.user"
      在 "權限設定 - 共用資料夾" 頁面, 在 "git-repo" 的 "可讀寫" 打勾.

   P.S. 以上各名稱可以自訂.

15. 修改 git.user 登入的家目錄, 跟 shell
  
   a) 在 Windows 下執行 SSH client (PuTTY) 以 'root' 登入至 NAS
      NOTE: 要求輸入密碼時請直接鍵入網頁管理頁面(admin)用的密碼.

   b) 編輯 /etc/passwd 文件.

      DiskStation> vi /etc/passwd

      P.S. 1. vi 預設一進入為 command mode, 左下方有一個 '-' 號
              移動游標 (方向鍵, 或 'h/j/k/l') 至想要編輯的地方
     
      2. 按 'i' (進入 insert mode, 左下方有一個 'I' 號)          
           3. 結束編輯後, 按 'Esc' key 回到 command mode
 
          4. 不存檔離開, 輸入 :q! 按 'Enter'
         
    存檔離開, 輸入 :wq 按 'Enter' 或直接輸入 ZZ

   c) 修改 "git.user" 那一行由
      git.user:x:1029:100:(描述):/var/services/homes/git.user:/sbin/nologin
      -->
      git.user:x:1029:100:(描述):/volume1/git-repo:/bin/ash

16. 設置 /volume1/git-repo 目錄

   NOTE: 建議修改 /volume1/git-repo 權限, 只有擁有者可讀寫.

      DiskStation> chmod 700 /volume1/git-repo

 
   a) 切換至 git.user
  
      DiskStation> su - git.user

   b) 確認此時家目錄已經為剛剛修改的路徑.
  
      DiskStation> pwd
      /volume1/git-repo

  
   c) NOTE: 參考網站此時有做建立 .profile .ssh authorized_keys 的動作, 但我沒做, 目前示每次連線都要輸入密碼, 不確定是否還有其他影響.

17. 測試建立一個新的 git 庫

DiskStation> mkdir test
DiskStation> cd test
DiskStation> git init --bare
Initialized empty Git repository in /volume1/git-repo/test/
DiskStation> ls
HEAD config hooks objects
branches description info refs

18. 測試連線抓上面的 git 庫

   Windows 端開啟 GIT Bash, 要求輸入密碼的地方(**), 輸入建立 git.user 時的私人密碼.

$git clone ssh://git.user@11.22.33.44/volume1/git-repo/test
Cloning into 'test'...
git.user@11.22.33.44's password:
warning: You appear to have cloned an empty repository.
$ls -a test/
. .. .git


或用 TortoiseGIT clone 頁面, URL 處輸入 "ssh://git.user@11.22.33.44/volume1/git-repo/test" 後按確定, 會彈出要求輸入密碼, 輸入後按
確定.

NOTE: (**)參考網站有一個步驟我沒有做, 應該可以避免每次連線都要輸入 SSH 密碼...Add public keys of your git users in...authorized_keys, 等下次有空再來試試看這個設置.

19. 測試 commit and push (to server)
   (這裡省略了, 就是那些基本的 git 操作...)


參考 How to setup a git server on a Synology NAS

2013年4月2日 星期二

如何在 (老) Synology NAS 設置 GIT 伺服器 (1/2)

NOTE: (08/11/2015) 本文是多年前的老機器 DS107 的紀錄, 這台機器的 DSM 已經停止更新, 當時他是無法透過 DSM 安裝 GIT 套件, 所以只能手動(ipkg)安裝, 最近購入 DS214 發現新的 DSM 上已經有套件可以直接安裝, 如果你的 DSM 有支援線上安裝 GIT Server 請不要再看本文, 參見 Synology Git 套件說明 或新版的 如何在 Synology NAS 設置 GIT 伺服器 (新版) ^^

========================================
本來想放棄用 NAS(with Linux) 這樣做, 但 google 了一下 GIT server 架在 Windows 或 Linux 給外網的人使用, 要搭 HTTP 或 SSH 等等, 安裝看來沒有誰比較簡單, 內網不管權限最簡單, 就是一個內部目錄位置就好了, 不然就是得用 FREE 或收費的 GIT HOST 雲端的服務. 所以還是嘗試看看...

NOTE: 這是我的私人記錄, 不是教學!

環境:

1. Synology DS107+ DSM 3.1-1636 版
2. 有實體 IP 11.22.33.44 (此為亂寫)

How to setup a GITserver on a Synology NAS
-------------------------------------------


1. 開啟 SSH

 
   a) 用瀏覽器打開 NAS 的網頁管理頁面 "11.22.33.44:5000"
   b) 打開 "控制台" -> "終端機" 在 "啟動SSH功能" 打勾,按 "確定".


2. 在 Windows 下執行 SSH client 以 'root' 登入至 NAS
   NOTE: 1. 要求輸入密碼時請直接鍵入網頁管理頁面(admin)用的密碼.

         2. 可以使用 Cygwin 的 ssh, 或是 PuTTY

$ ssh 11.22.33.44 -l root -p 22
root@11.22.33.44's password: xxxx

BusyBox v1.16.1 (2011-10-23 04:33:17 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.



NOTE: 一般 SSH 預設 port 為 22 如果沒有改過, -p 22 可以不用加.

3.  進入 /volume1/@tmp

DiskStation> cd /volume1/@tmp
DiskStation> ls -al
drwxrwxrwx    4 root     root          4096 Mar 25 15:25 .
drwxrwxrwx   12 root     root          4096 Apr  2 11:10 ..
drwxrwxrwt    3 root     root          4096 Mar 25 15:25 php
drwxrwxrwx    2 root     root          4096 Apr  1 18:53 webfm

4. 抓取 bootstrap
   NOTE: 1. bootstrap 是安裝 ipkg 的執行劇本, 各 CPU 不一樣, 請先看好機

            型的 CPU.
            What_kind_of_CPU_does_my_NAS_have
            看好要下載正確的 xsh 文件 URL 位置:

            Modifying_the_Synology_Server,_bootstrap,_ipkg_etc
         2. 為避免網址輸錯, 建議直接複製 xsh 文件的網址, 下面 wget 後面直

            接 "貼上".

DiskStation> wget http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/syno-x07-bootstrap_1.2-7_arm.xsh
--16:47:02--  http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/syno-x07-bootstrap_1.2-7_arm.xsh
           => `syno-x07-bootstrap_1.2-7_arm.xsh'
Resolving ipkg.nslu2-linux.org... 140.211.169.161
Connecting to ipkg.nslu2-linux.org|140.211.169.161|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 250,349 (244K) [text/plain]

100%[====================================>] 250,349      190.89K/s

16:47:04 (190.41 KB/s) - `syno-x07-bootstrap_1.2-7_arm.xsh' saved [250349/250349]

DiskStation> ls -al
drwxrwxrwx    4 root     root          4096 Apr  2 16:47 .
drwxrwxrwx   12 root     root          4096 Apr  2 11:10 ..
drwxrwxrwt    3 root     root          4096 Mar 25 15:25 php
-rw-rw-rw-    1 root     root        250349 Feb 20  2012 syno-x07-bootstrap_1.2-7_arm.xsh
drwxrwxrwx    2 root     root          4096 Apr  1 18:53 webfm

5. 改變 script 為可執行屬性

DiskStation> chmod +x syno-x07-bootstrap_1.2-7_arm.xsh

6. 執行 script

DiskStation> sh syno-x07-bootstrap_1.2-7_arm.xsh
Optware Bootstrap for syno-x07.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1226+1 records in
1226+1 records out
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Setting up ipkg arch-file
Modifying /etc/rc.local
Done.
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...WARNING: can't open config file: /usr/syno/ssl/openssl.cnf
Done.
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.

BusyBox v1.16.1 (2011-11-26 14:58:46 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

7. 刪除 script

DiskStation> rm syno-x07-bootstrap_1.2-7_arm.xsh

8. 如果是 DSM 4.0 還需要修改 /root/.profile

   (....P.S. 我是 DSM 3.1 所以此處我是跳過)

   請參考下面連結, 第八步驟 NEW: If you have DSM 4.0 there is an additional step...
   Modifying_the_Synology_Server,_bootstrap,_ipkg_etc

9. 執行 ipkg update

DiskStation> ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/Pa
ckages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/Pack
ages.gz
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.

10. 執行 ipkg upgrade

DiskStation> ipkg upgrade
Nothing to be done
Successfully terminated.

11. 安裝 git

DiskStation> ipkg install git
Installing git (1.8.2-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/git_1.8.2-2_arm.ipk
package git suggests installing git-manpages
Installing zlib (1.2.5-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/zlib_1.2.5-1_arm.ipk
Installing openssl (0.9.7m-6) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/openssl_0.9.7m-6_arm.ipk
Installing libcurl (7.24.0-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/libcurl_7.24.0-1_arm.ipk
Installing diffutils (3.1-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/diffutils_3.1-1_arm.ipk
Installing rcs (5.7-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/rcs_5.7-2_arm.ipk
Installing expat (2.0.1-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-x07/cross/unstable/expat_2.0.1-1_arm.ipk
Configuring diffutils
update-alternatives: Linking //opt/bin/cmp to /opt/bin/diffutils-cmp
update-alternatives: Linking //opt/bin/diff to /opt/bin/diffutils-diff
update-alternatives: Linking //opt/bin/diff3 to /opt/bin/diffutils-diff3
update-alternatives: Linking //opt/bin/sdiff to /opt/bin/diffutils-sdiff
Configuring expat
Configuring git
Configuring libcurl
Configuring openssl
Configuring rcs
Configuring zlib
Successfully terminated.

13. 設置 git 的各命令可以不帶路徑直接叫用
    P.S. 這是因為 ipkg 安裝 git 是放在 /opt/bin 下, 非系統的 $PATH 下能找到, 有兩個方法:


    a) 最簡單的方式是...建立檔案連結 ("有點" 像 Windows 的捷徑).

DiskStation> for f in `ls /opt/bin/git*`
> do
> ln -s $f /usr/bin    
> done

    b) 在建立 git user 後修改的 login 環境變數.

       (....我是用 a 法, 所以此處我沒試)

       請參考下面連結, 第6步驟 ..."git-upload-pack" on the NAS was not found in the $PATH....
           

14. 建立 git 帳號及共享目錄

繼續...如何在 Synology NAS 設置 GIT 伺服器 (2/2)

參考:
http://ti57.blogspot.tw/2013/01/how-to-setup-git-server-on-synology-nas.html
http://www.wonko.de/2010/04/set-up-git-on-synology-nas.html


2012年2月23日 星期四

SVN folder as sub module of GIT

這是上一篇中 '方法B' 的筆記

1) Prepare svn:// protocol:

(NOTE: don't use file:/// because it might has file format compilable problem)

In my case:

    1. svn repo at d:\work\repo\my_projects

    2. set svn service (I had set root at d:\work\repo) and make sure service was activated

    3. test svn checkout from svn://localhost/my_projects (or relative to yout root  in step2) has no polblem

    where repo tree is like:

    svn://my_projects/bla1/...
                     /bla2/...
                     /src/boo1/...
                     /src/boo2/...
                     /src/boo3/...
                     /src/...


    (NOTE: I don't use /trunk /branches /tags naming layout)
 

2) Purpose: 

the svn://my_projects/src/boo3/* is the library part, I need it to be used as

a git clone where in d:\work\my_test\boo3-clone

so git://d:\work\my_test\boo3-clone

will sync to/and from svn://localhost/my_projects/src/boo3


3)  using msysgit:

1. use GIT for windows' 'GIT bash here' at d:\work\my_test

2. use 'git svn clone url_of_svn_repo folde_rname

(NOTE: if using /trunk /branches /tags naming layout, use 'git svn clone -s ...' as -s is -stdlayout)

3. in my case

$ git svn clone svn://localhost/my_projects/src/boo3 boo3-clone
Initialized empty Git repository in d:/work/my_test/boo3-clone/.git/
r75 = 1324d83fab0b6d93f526b8f8252e8404d49c9e08 (refs/remotes/git-svn)
        A       boo3.vcxproj.user
...
        A       boo3.dsw
        A       boo3.vcxproj.filters
        A       boo3.dsp
r80 = 9f6afc8b5c2d68c4901de44a99e946b9edab5926 (refs/remotes/git-svn)
..
        M       boo3.dsp
r81 = cbb1be75466bfb695c76c8366828af3fd7c03a80 (refs/remotes/git-svn)
Checked out HEAD:
  svn://localhost/my_projects/src/boo3 r81


4. so now d:\work\my_test\boo3-clone had filled as a git repo where all files/folders/logs

   are the same as svn's

Ref: 使用 git-svn 整合 git 與 svn



 4) Another example by using TortoiseGit:

1. git svn clone setup


2. git svn clone done


3. add submodule


GIT 跟 SVN 一起工作的實驗作法...

情景:
-----
工作在 A project, 其中有一個子模組 B 是來自其他的 SVN controlled project

方法 A:
-------
目前的實驗作法, 是將子模組 B 當成一個目錄, 然後整個 svn checkout 到到該目錄, 此

時可以把他當作 project A 的一個目錄(與其他的目錄一樣) import/commit to GIT

A-+-B-1.c
  |   2.c
  |
  +-C-3.c
  ...

如上圖, 整個 A 是 GIT 控制的, 而 B 目錄是 checkout from SVN,

工作時以 GIT 為主, 如果有修改 1.c, 2.c 也把修改送上 GIT,

唯需要將 1.c, 2.c 的修改也送回 SVN (可以每次 GIT commit 後, 或累積數次) 時,

則切到 B 目錄上操做 SVN 的 commit 動作.

如果 B 的 SVN 源頭有新的修改, 也是在 B 目錄上操作 SVN update(or merge),

然後再 GIT commit 此次的 B 的 SVN update.

問題:
-----
B 目錄(並其子目錄) 下會有一大堆 .svn\* 的控制目錄(可能被隱藏起來)跟檔案.

GIT 不應該管控他, 如果這些檔案被送交 GIT, 則不適當的順序(commit 1.c, 2.c 沒有依先

SVN commit, 再 GIT commit...)操作, 有可能會毀掉 B 的 .svn 的控制.

解決:
-----

就不要把 .svn 之類的目錄跟檔案送進 GIT 控制, 方法是利用在 A 目錄(GIT project 根目錄)下

放一個 .gitignore 文字檔案.

裡面一行文字描述要 GIT 忽略的檔案類型

.svn*

p.s. 建議可以多加一些可忽略的檔案格式(如每次 build VS6/VS2010 都會重新產生的檔案)

.svn*
*.obj
*.pch
*.idb
*.pdb
*.log
*.tlog
*.suo
*.user
*.aps
*.clw
*.ncb
*.opt
*.plg

問題:
-----
如果是 M$ Windows 下, 是不永許產生"無前檔名"的文件 :(

解決:
-----

利用 msysgit 的 bash 環境產生!

開啟 GIT bash 切到 A 目錄下(或在目錄 A 上執行右選單的 GIT Bash here), 執行

>touch .gitignore

看看有沒有產生

>ls -al

explorer 打開目錄 A window, 也能看到 .gitignore, 此時用任何編輯器編輯他...

編輯好後存起來, 可以在 GIT bash 裡面切到 B 目錄, 執行

>git status

應該看不到 .svn 了...

git commit 時, 這些 .gitignore 裡面描述的檔案也是 "不會出現"




方法 B:
-------
一般比較正統的作法是用 git-svn 指令, 見 svn folder as sub module of git 描述方法

我實際試用了一次:

1. clone svn 步驟是需要學習的.

2. [印象中] 在我實際(當前 GIT) project, 我只要 SVN repo 個的一個子目錄(模組), 而非全部目錄,

   不容易這樣子做, 我試了許久, 繞了一圈有做出來, 但又好像怪怪的...

3. [印象中] 可以直接一次 git commit 就送回 SVN repo, 這是方法 A 不及的.

以上 [印象中] 因為時間過太久了, 我忘了為什麼又放棄此法, 有時間我還要再驗證一次.

2012年2月13日 星期一

TortoiseGIT 1.7.7 有感

從去年(2011)七月開始試用 GIT, 雖然一開始不太習慣, 但還是被他的快速吸引, 並有一些功能很特殊 like stash save 等, 只是我是一個 GUI 控, 版本控制用標準的命令列操作要記一堆指令跟打字, 我絕對無法面對, 我一直以來都是 TortoiseSVN 的愛用者, 當然就立刻裝了 TortoiseGIT 1.5 來用看看, 只是試用了一下, 充滿無奈, 有幾個嚴重的問題, 特別是 overlay icons 不正確, 如果直接由彈出選單操作也無法正確顯示有哪些檔案被修改過, 甚至會列出一大堆沒有修改的標為改過! 以上是 Tortoise 系列最重度需要的特色, 一度我開始找其他的 Free GUI clients 替代方案, like Git Extensions, SmartGIT 等, 試裝了結果又砍了, 因為操作直覺不順利, 其 UI 也醜, SCM 是每天必要的工具, 要快, 要順才對!
PC 上的 GIT clients 方案沒幾個, 試了一輪, 只好又回到 TortoiseGIT 上, 在其 issues 上參加討論 (有幾次使用上遭遇問題, 還會想乾脆來幫忙看怎麼修改? 只是自救都無暇了還幫人, 還是放棄該念頭.), 並改了用 nightly build 跟隨著, 因為我只用一個私人的小專案在 GIT 上, 所以輔助 MsysGIT GUI 一起操作還行, 所幸 TortoiseGIT 作者是積極的開發, 最後跟到 1.7.6 最後幾個 nightly build 我在乎的幾個問題都解了, 前幾日放出正式的 1.7.7, 謝謝該作者在開放軟體上無私的付出...
P.S. 不過美話說回來這幾版的 TortoiseGIT commit 花太多時間在 preparing (每次都要掃瞄目錄裡全部的文件!), 這好像比以前慢了(*)!?

(*)3/22 修正 : 過慢問題已經在 Issue 1085  提出並獲得修正,目前沒什麼可以挑剔的, 繼續使用了..

2011年8月3日 星期三

Install the Bug Genie 3.x step by step



Install the Bug Genie 3.x
-------------------------------------------------------------------------------

(3.1.3 tested)

1. install the Apache 2.2.x (2.2.19 Apache Lounge Build tested)

see my Readme.txt in "Apache HTTP Server v2.2"\

2. install the PHP 5.2.x/5.3.x with MySQL extentions (5.3.6-VC9 tested)

see my the Readme.txt in "PHP v5.2_5.3"\

NOTE: need to setup timezone in php.ini

a) in php.ini find

[Date]
; Defines the default timezone used by the date functions
;date.timezone =

b) modify as

[Date]
; Defines the default timezone used by the date functions
date.timezone = Asia/Taipei

c) restart Apache

3. install MySQL 5.5.x (5.5.12 tested)

see my Readme.txt in "MySQL v5.5"\

4. install the phpMyadmin 3.x (3.4 tested)

see my Readme.txt in "phpMyadmin v3.4"\

5. Create a database 'thebuggenie'

STEP1: open url http://127.0.0.1/phpMyAdmin/index.php

in login screen enter 'root' as username and your password to access

MySQL

STEP2: in home page, click 'Databases' tab

STEP3: in Create new database fields, enter 'thebuggenie' and select

'utf8_general_ci' as collation option

STEP4: click 'Create' button

6. download and unzip thebuggenie_3.x.zip to ..\Apache folder\htdocs\bugs\

7. open url http://127.0.0.1/bugs/thebuggenie/index.php in http browser,

in first time it will setup the Bug Genie

STEP1: in the license statement, pick 'I agree...' and click 'Continue' button

STEP2: after checking the prerequisites, click 'Start installation' button

STEP2: in Database information, enter 'root' as username and your password

to access MySQL

STEP3: in Connection information, enter thhe hostname of the database, if it

is in the local computer just enter 'localhost'

NOTE: the port num here is for database connection! This is different

from http, please remain empty if no changed

STEP3: click 'Continue' button

STEP4: it will show 'All tables were created successfully...'

in the The Bug Genie URL information, check if all are valid,

click 'Continue' button

STEP5: it will show 'Apache .htaccess auto-setup completed successfully...',

click 'Continue' button

STEP6: remember the Administrator account, you should change it later

Username: administrator

Password: admin

STEP7: click 'Finalize installation' button

9. activate mod_rewrite module on Apache

STEP1: edit [Apache folder]\conf\httpd.conf

STEP2: find follow line

#LoadModule rewrite_module modules/mod_rewrite.so
-->
LoadModule rewrite_module modules/mod_rewrite.so

STEP3: make sure follow line not be commented

-->
Options Indexes FollowSymLinks

STEP4: find follow line

AllowOverride None
-->
AllowOverride All

STEP5: make sure follow lines be

-->
Order allow,deny
Allow from all

STEP6: restart Apache server and check again if mod_rewrite works

a) create .htaccess file with the code:

RewriteEngine on
RewriteRule ^first.html$ second.html

b) create 2 html files named first.html and second.html and write 1,

2, or first and second in them so that you could easily distinguish

that in first.html a word “first” is written. Put those 2 files in

the same folder where you put .htaccess file.

c) load first.html via localhost. Your mod_rewrite works if you see

first.html in the address bar but word “second” displayed in the page

8. open url http://127.0.0.1/bugs/thebuggenie/index.php


NOTE: 1. you can edit [Apache folder]\conf\httpd.conf, find

'DirectoryIndex' line and add 'index.php' in the end of line with space

ahead, so it can open index.php by http://127.0.0.1/bugs/thebuggenie/ directly

2. you could also create an alias for Apache2, add below lines into

httpd.conf, so it can open http://127.0.0.1/work/


Alias /work/ "C:/Apache2/htdocs/bugs/thebuggenie/"

AllowOverride all
Order allow,deny
Allow from all



-------------------------------------------------------------------------------

Q: got 'An unhandled exception occurred: date(): It is not safe to rely on the

system's timezone settings...."

A: The Bug Genie requires php to configure the default timezone correctly.

Please see step 2's note

--OB