顯示具有 Git 標籤的文章。 顯示所有文章
顯示具有 Git 標籤的文章。 顯示所有文章

2011年12月27日 星期二

使用BitBucket來管理你的程式碼



BitBucket是一個網路服務,他提供了使用者免費的版本控制系統來管理程式碼。
並且提供issue tracking和wiki的功能。

其實這類型的網站挺多的,以Git來說最有名的就是Github。不過Github有個缺點是沒辦法免費開私人的Repository,所有的專案都必須公開,不然就是要花錢購買。

最近,BitBucket 開始支援Git。BitBucket最大的優點就是沒有限制私人Repository的個數。唯一的限制是使用者不能超過5個人
(5 users free plan and you can have unlimited public and private repositories.)
官網對user的定義為Someone with read or write access to one of your private repositories
簡單來說,如果整個專案少於五人參與開發的話,這個限制對你來說完全沒影響
於是我決定把一些私人的專案搬到BitBucket上試用看看,註冊的方法很簡單

連結到首頁https://bitbucket.org/,點選Sign up for free

輸入帳號密碼和信箱(信箱會收到驗證信)

輸入基本資料

成功建立帳號後,可以點選create a repository來建立新的repository
或是點選Import an existing repository來Import其他地方建立的專案,比如說從Github, Google Code, SourceForge......


輸入專案名稱和使用語言,當然別忘了設定Repository type為Git

接下來就可以開始上傳程式碼了,這邊不詳細講解Git的指令,只示範如何上傳到BitBucket
首先先輸入git clone把剛才建立的repository複製一份下來,這邊假設專案名稱為bbs_parser
swaywang則是你的BitBucket帳號
sway:~$ git clone https://swaywang@bitbucket.org/swaywang/bbs_parser.git
建立一個上傳測試用的Python程式
sway:~$ echo "print 'Hello World'" > hello.py
把hello.py加入到Server上
sway:~$ git add hello.py
commit,並且夾帶訊息
sway:~$ git commit -m "Print Hello World"
最後push到Server上
sway:~$ git push -u origin master




最後在個人首頁就可以發現程式已經被傳上去了
之後要再建立repository只需要點個人首頁中的create a repository連結即可

最後推廣大家一起來使用Git,Git的優點可以參考下列這個網站
http://git-scm.com/about