31
Git Basic Browny 2010.12.06

Git basic

Embed Size (px)

Citation preview

Page 1: Git basic

Git Basic

Browny2010.12.06

Page 2: Git basic

Outline

• Introduction to Git• Install Git• Basic Commands• Git Branch• Git and Dropbox• Resources

Page 3: Git basic

rcs

Page 4: Git basic

Centralized Version Control System (CVCS)

• CVS• Subversion• Perforce• etc…

Page 5: Git basic

Distributed Version Control System (DVCS)

• Git• Mercurial• Bazaar• etc…

Page 6: Git basic

Snapshot, not Differences

CVS

Git

Page 7: Git basic

Flow

Page 8: Git basic

Outline

• Introduction to Git• Install Git• Basic Commands• Git Branch• Git and Dropbox• Resources

Page 9: Git basic

Install Git on Windows

• msysgit - http://code.google.com/p/msysgit/

Page 10: Git basic

Initialization

• 設定 ID 和 Email$ git config --global user.name “browny" $ git config --global user.email [email protected]

• 查看設定資料$ git config --list

Page 11: Git basic

Outline

• Introduction to Git• Install Git• Basic Commands• Git Branch• Git and Dropbox• Resources

Page 12: Git basic

Basic Commands (1)

• 初始化一個 git 倉庫$ git init

• 將檔案放入暫存夾等候 commit$ git add

• 指定要忽略 commit 的檔案 (create a file in your repo named .gitignore)*.[oa] :忽略所有 .o 和 .a 檔案*~ :忽略所有 ~ 檔案

Page 13: Git basic

Basic Commands (2)

• 觀看狀態$ git status

• 提交 $ git commit

• 幫某次 commit 加上含附註的標籤 tag$ git tag –a v1.1 –m ‘version 1.1’

• 觀看提交歷程$ git log

Page 14: Git basic

Basic Commands (3)

• 複製遠端 repo.$ git clone git://github.com/schacon/grit.git

• 自定義複製來的 repo. 名稱$ git clone git://github.com/schacon/grit.git mygrit

Page 15: Git basic

Basic Commands (4)

• 查看現有的分支$ git branch       

• 建立新的分支$ git branch 分支名稱

• 切換到主幹上$ git checkout master 

• 切換到某個分支上git checkout 分支名稱

Page 16: Git basic

Outline

• Introduction to Git• Install Git• Basic Commands• Git Branch• Git and Dropbox• Resources

Page 17: Git basic

First Commit

Page 18: Git basic

Multiple Commit

Page 19: Git basic

master

Page 20: Git basic

Make a branch

• $ git branch testing

Page 21: Git basic

Re-direct HEAD

• $ git checkout testing

Page 22: Git basic

Commit on testing

Page 23: Git basic

Back to master

• $ git checkout master

Page 24: Git basic

Commit on master

Page 25: Git basic

Outline

• Introduction to Git• Install Git• Basic Commands• Git Branch• Git and Dropbox• Resources

Page 26: Git basic

Dropbox Setting

Page 27: Git basic

Set up cloud repo.

• Make a directory in Dropbox $ mkdir /GitRepo/opencv-gradient.git$ cd /GitRepo/opencv-gradient.git

• Initialize it $ git init --bare

Page 28: Git basic

Push repo. to Cloud

• Go to your work directory $ cd /EclipseWork/opencv-gradient

• Add a remote alias (git remote add alias URI)$ git remote add drop-opencv-gradient file:///C:/Documents%20and%20Settings/....../GitRepo/opencv-gradient.git

• Push working repo. to Dropbox repo.$ git push drop-opencv-gradient master

Page 29: Git basic

Get repo. from Cloud

• git clone URI directoryName• $ git clone file:///C:/Documents%20and%20Settings/....../GitRepo/opencv-gradient.git opencv-gradient

Page 30: Git basic
Page 31: Git basic

Resources

• Git - http://git-scm.com/• Pro Git 簡體翻譯 -

http://progit.org/book/zh/• Git 初學文件整理 | Tsung's Blog -

http://plog.longwin.com.tw/my_note-unix/2009/05/14/git-learn-initial-document-2009