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

2013-02-24

Git Branch

Git Branch 是 Git 另外一項狂電其他版本控管系統的功能,因為它實在太輕量了,太簡單用了。
> git branch
* master  // 開發主軸事實上是一個叫做 master 的 branch

> git branch test  // 建立名為 test 的 branch

> git branch  // 有兩個 branch,目前在 master
* master
  test

> git checkout test  // 切換到 test 這個 branch
Switched to branch 'test'

> git branch  // 有兩個 branch,目前在 test
  master
* test

> git status  // 目前在 test 這個 branch
# On branch test
nothing to commit (working directory clean)

> git checkout master  // 切換回 master 這個 branch
Switched to branch 'master'

> git status // 目前在 master 這個 branch
# On branch master
nothing to commit (working directory clean)
Git Branch 就是強在可以在同一個專案裡快速切換 branch。

Git Tag

Tag(標籤)可以用來標注重要的時間點,例如 v1.0 或 v2.0。

Git 提供兩種標籤:Lightweight 與 Annotated,Lightweight 標籤就只是一個標籤,沒有紀錄其他訊息,而 Annotated 標籤則紀錄了較多資料。

Git Remote

要跟遠端搭上線有兩種作法:
  • 使用 git clone 從遠端複製既有的專案到本機
  • 使用 git remote add 與 git push 將本機的專案送到遠端

使用 git clone
> git clone https://cw1057@bitbucket.org/cw1057/test.git bproject.git

Cloning into 'bproject.git'...
Password for 'https://cw1057@bitbucket.org':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.

2013-02-13

Git 常用指令

在 Hello Git 紀錄了最基本的指令。
git init
git clone
git add
git rm --cached
git commit
git push
接下來就來看看常用的指令。
git checkout -- [file]
git reset HEAD [file]
git commit -a
git rm
git rm -f
git rm --cached
git mv

2013-02-11

Hello Git

Git 是什麼?

版本控管系統,就像是 CVS 或 SVN(Subversion)。

為什麼要用 Git 取代 SVN?

不同於 CVS 或 SVN 這類中央控管型的版本控管系統,Git 是分散式版本控管系統。

什麼是分散式版本控管系統?

CVS 或 SVN 只有一個遠端的檔案庫(repository),分散式版本控管系統有兩個檔案庫,本地端與遠端,就像是本機有一個 SVN Server,供本機專用,而這個本機 SVN Server 又可以和遠端多人共用的 SVN Server 進行同步。