git 學習筆記

這裡我們要介紹 git 這個分散式版本控制軟體. 有人可能會聽過 ‘github’. 不過這邊要提醒一下 git 跟 github 是不一樣的兩件事. 簡單的說 git 是一個軟體, 而 github 則是提供線上 git 服務的公司.


git 教學網頁

  1. 我非常推薦 為你自己學 Git, 尤其務必熟讀以下三章, 才算是對 git 有最基本的認識.
  • 二、Git Windows/Mac/Linux 環境安裝
  • 四、設定 Git
  • 五、開始使用 Git
  1. 快速上手 git 版本控制, slideshare

git 基本指令 (terminal 終端機):

  • 做完某個段落後, 將檔案 XXX 移進暫存區
git add XXX

或是將剛剛所有編輯過的檔案一起移 進暫存區

git add .

接著將暫存區的檔案移至儲存褲 (repo), 並且記註做了什麼事

git commit -m "我做了XXX"

支援 git 的網站

github

如同我最初說的, github 是一個支援 git 的網站, 可以讓你擺放你程式的原始碼, 基本服務是免費的, 有一些更進階的功能則需要付費.

bitcuket

  • 也可以使用 bitcuket, 一樣是個讓你把原始碼放上雲端的免費服務.

git <-> github 基本指令 (terminal 終端機):

  • 丟上雲端 (github 或 bitbucket)
git push
  • 從雲端下載最新版本
git pull

簡單工作示意圖:

graph TD;
  A[工作資料夾]-->|add| B;
  B(本機 local 暫存區)-->|commit| C;
  D-->|pull| C;
  C(本機 local repo)-->|push| D{雲端 repo};

git 觀念釐清

  1. git fetch 與 git pull 的區別

Avatar
Te-Sheng Lin (林得勝)
Associate Professor

The focus of my research is concerned with the development of analytical and computational tools, and further to communicate with scientists from other disciplines to solve engineering problems in practice.