iammic 一直需要一個簡單的本機程式原始碼管理工具,之前的經驗一直還停留在使用 CVS 的

情況,然而最近才發現 Git ,他與CVS 跟 SVN 有很大的差異,Git 是個分散式的版本控制軟體

,在本機中會擁有一份完整的 repository,自己可以對本機的 repository 進行操作,而不需

要連回 Server 端,當需要傳回資料或更新資料到 remote 時才使用 git push 或 git pull 。

 

windows 版的 git 下載 。

http://code.google.com/p/msysgit/downloads/list?can=3

git 使用:

設定一下使用者名稱與 email

$git config --global user.name "test" #設定名稱
$git config --global user.email test@mail.com #設定 email

建立一個 Git Repository

$mkdir test
$cd test
$git init

加入檔案

$echo test > test #產生一個檔案
$git add . #加入檔案到暫存區
$git commit -m "test" #commit 檔案到 repository

回復到前一次狀態

$git reflog #看一下 log
$git reset --hard HEAD~1 #回復到前一次狀態
$git reset --hard HEAD~2 #回復到前兩次狀態

checkout 之前的版本

$git log filename #使用 log 看一下自己要回復到的版本
$git checkout HEAD~1 filename #回復到前一版
$git checkout HEAD~2 filename #回覆到前兩版

取得目前狀態

$git status

 

如果對 git 的概念還不是很清楚,則可以看一下以下 Video,相信看完之後會更快上手喔。

http://excess.org/article/2008/07/ogre-git-tutorial/

 

參考網站:

http://people.debian.org.tw/~chihchun/2009/01/05/understand-git-in-one-hour/

http://excess.org/article/2008/07/ogre-git-tutorial/

http://git-scm.com/documentation

arrow
arrow
    全站熱搜

    iammic 發表在 痞客邦 留言(0) 人氣()