2016年2月2日 星期二

Git 基本操作

名詞概念

Branch
在repository中分出來的另一條development path.
Check out:
請求一個file的copy, 以作修改.
Clone:
請求一個repository的copy, repository可以是在本機的(locally)或遠程的(remotely), 如GitHub.
Commit:
把修改保存到到repository中, 同都記錄timeline.
Distributed:
分散式系統, 不需要中央服務器控制repository.
Repository:
儲存files的地方, 在version control裡通常是指一個directory, 根據你的project組織方式, 通常會包括一些sub directories及files.
Staging area:
Git的獨有功能, 可以不用整個file去commit, 而只commit file的部份內容.
Timeline:
也可叫history, 一連串按時間排序的事件(event).
Version control:
一種持續記錄files修改歷史的方法, 可以隨時回覆到任何一個timeline.

設定姓名及Email

% git config --global user.name "Your Name"
% git config --global user.email "Your E-mail@example.com"

讀取Git設定

% git config user.name
% git config --list

初始化repository

% cd myProject
% git init

檢查repository狀態

% git status

把file加入repository

% git add filefixup.bat

commit修改

% git commit -m "This is the first commit message"