Git 簡介(古時候的簡報備份)

25
Git 簡介 資工4A 952847 鄭新霖 [email protected] 2010.01.15

Transcript of Git 簡介(古時候的簡報備份)

Git 簡介

資工4A 952847鄭新霖

[email protected]

甚麼是 Git?

Git --- The stupid content trackerhttp://git-scm.com/分散式 SCM自由軟體 (Freeware)開放原始碼 (Open Source)速度很快

簡單易用的分支 (Branch) 系統由 Linux 之父 Linus Torvalds主導開發

Linus recommends Windows7http://www.flickr.com/photos/christaleye/4033726325/

緣起

2002年,Linus Torvalds採用封閉式的 BitKeeper (bk) 分散式版本控制系統,降低日趨複雜的開發管理難度

自由軟體之父 Richard Stallman 為此提出警告,Linux 重要的核心開發者相繼拒用 bk“Freedom is more important than

convenience.” -- Richard Stallman 2005年,Linus Torvalds開始著手建立新的分散式 SCM -- git

Linux kernel 平均以每小時 85.6 行的速度增加http://mirror.celinuxforum.org/gitstat/index.php

Linus Torvalds on git

http://www.youtube.com/watch?v=4XpnKHJAok8Linus在 Google Tech Talk 的演講

Staging Area

Git 的分支 (Branch)

“Branches are cheap and easy, so this is a good way to try something out.”

適用任何工作流程 (workflow)

Subversion 式的工作流程整合管理員工作流程

司令官與副手的工作流程

Subversion 式的工作流程

整合管理員工作流程

司令官與副手的工作流程

GitHub

http://github.com/使用者導向/社交導向的 repository hosting

設定個人資訊

$ git config --global user.name “Hsin-linCheng”$ git config --global user.email“[email protected]

建立 Repository在本機端建立

$ cd hello-world$ git init

或是由遠端 repository 複製$ git clone git://github.com/git/hello-world.git

為遠端的 repo 建立識別,如 hw2$ git remote add hw2 git://github.com/git/hello-world2.git$ git fetch hw2

整合 hw2 repository 到 master branch$ git merge min/master

Creating and Commiting進入專案資料夾

$ cd (project-directory) 建立一個 git repository

$ git init 新增一些程式碼或文件

$ (add some files) 把這些檔案通通加入 git管理

$ git add . 將這些檔案簽入 repository

$ git commit -m 'Initial commit'

Cloning and Creating a Patch從 github的專案 hello-world 的 repo 中複製一份回來

$ git clone git://github.com/git/hello-world.git進入專案資料夾

$ cd hello-world 新增或修改一些檔案

$ (edit files) 將新增修改後的檔案加入 git管理

$ git add (files) 簽入 repository

$ git commit -m 'Explain what I changed' 產生 patch 檔案

$ git format-patch origin/master

diff & show比較目前的修改與 repository 的差異

$ git diff HEAD比較 staging area 跟 repository 的差異

git diff --cached 看看修改了甚麼

$ git show HEAD # 此版本修改的資料$ git show HEAD^ # 前一版修改的資料$ git show HEAD^^ # 前前一版修改的資料$ git show HEAD~4 # 前前前前一版修改的資料

上傳資料到遠端 repository$ git push

下載遠端資料至本機 repository 並且自動 merge$ git pull

branch新建一個分支

$ git branch experimental切換到此分支

$ git checkout experimental看看目前有哪些分支

$ git branch切回主分支

$ git checkout master刪除分支

$ git branch -d experimental

merge

將 experimental 分支與主分支合併$ git checkout master$ git merge experimental將別人的成果與自己的 repository 合併

$ git fetch someone$ git merge someone/master

Git Cheat Sheet

http://jan-krueger.net/development/git-cheat-sheet-extended-edition

References我愛Git - jserv

http://jserv.sayya.org/writing/loving-git.pdfLinus Torvalds on git

http://people.debian.org.tw/~chihchun/2008/12/19/linus-torvalds-on-git/Why Git is Better than X (中文版)

http://zh-tw.whygitisbetterthanx.com/Git on Windows

http://www.gitcasts.com/posts/git-on-windowsTortoiseGit

http://code.google.com/p/tortoisegit/使用 git來 mirror CVS repository

http://cyt93cs.pixnet.net/blog/post/26629828[Geek] Git and Gitweb

http://walkingice.twbbs.org/blog/?p=504Git Study

http://josephjiang.com/entry.php?id=308

Thanks you!