iT邦幫忙

DAY 4
2

一個月學會Ruby on Rails系列 第 4

One Month Rails - Day4 - Git 申請及設定

以one month rails的線上課程及codecademy的Ruby課程,紀錄及分享一個月來學習的歷程及心得。
昨天介紹如何啟動rails server: http://ithelp.ithome.com.tw/question/10129491
今天來來分享如何利用Git做版本控制吧

什麼是Git?
Git是一套版本控制的工具,尤其是開發團隊不可或缺的工具。
omrails裡沒有提到太多細節,但基本的幾個指令對初學的我也算是足夠應用了。

如果想更深入瞭解Git,這裡推薦兩個台灣的Blog。
Tsung’s Blog: http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/
好麻煩部落格:http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/

第一步,設定一組git帳號:
$ git config --global user.name "Your Name" # 設定你的Git名字
$ git config --global user.email youremail@gmail.com # 設定一組email
以上兩個步驟像是在註冊,只會執行這一次

第二步,ignore不需要追蹤的檔案:
在教學中講到,此時在終端機打上 $ git status,會出現一些我們不想放上git作追蹤的檔案,例如mac自動產生的.DS_Store。
這時就要打開Sublime Text找出一個檔案叫.gitignore,將以下的code貼上:

Ignore bundler config

/.bundle

Ignore the default SQLite database.

/db/*.sqlite3

Ignore all logfiles and tempfiles.

/log/*.log
/tmp
doc/
*.swp
*~
.project
.DS_Store
.idea

第三步,開始追蹤:
$ git init # Set up Git on your project
$ git status # 看目前哪些檔案還沒track
$ git add . # 新增檔案到Git
$ git commit -am "Initial commit" # 儲存檔案到Git

今天完成了git的設定,明天會講到Github帳號申請及基本使用教學,請多多指教。


上一篇
One Month Rails - Day3 - 新增專案
下一篇
One Month Rails - Day5 - Github 申請及設定
系列文
一個月學會Ruby on Rails8
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言