Git Littlebtc (Hsiao-Ting Yu) Scott Chacon Pro Git CC-BY-NC-SA-3.0
What is Version Control? What is Git?
Local rcs
Server Checkout Commit Subversion SVN Server
Server git, Mecurial (hg), bazaar (bzr) Branch
Git Linux Kernel (http://en.wikipedia.org/wiki/linux_kernel, Wikipedia contributors, CC-BY-SA)
From: Linux Kernel Development: How Fast it is Going, Who is Doing It, What They are Doing, and Who is Sponsoring It, Fair use(?)
先前的嘗試 BitKeeper Linus Torvalds 我就是不喜歡中 央式的系統 所以 Linux Kernel 以前的變更都是用 Patch + 壓 縮檔來散布 2002年 Linus 採用 BitKeeper 分 散版本控制系統 專有 社群不滿 甚至嘗試逆向工程 於是跟 BitKeeper 開發商鬧翻 Git 因此而生 (pic: http://commons.wikimedia.org/wiki/file:linus_torvalds.jpeg CC-BYSA-3.0 & GFDL)
Git Linux Kernel And then realize that nothing is perfect. Git is just *closer* to perfect than any other SCM out there. -- Linus on Git mailing list
Git Basics
Git
Git...
Git Checksum Staging
Using Git
Git Repository Repository git init.git
Initial Commit README touch README git add. git commit -m 'Initial commit'
Repository Clone $ git clone http://github.com/jquery/jquery.git Initialized empty Git repository in /Users/littlebtc/work/jquery/.git/ remote: Counting objects: 14043, done.remote: Compressing objects: 100% (4070/4070), done. remote: Total 14043 (delta 9717), reused 13753 (delta 9452) Receiving objects: 100% (14043/14043), 12.45 MiB 288 KiB/s, done. Resolving deltas: 100% (9717/9717), done.
File Status git checkout -- filename git reset HEAD filename git add filename git add filename git rm filename git commit.gitignore.gitignore commit! git status
git status
Commit log git log (console) GitX (Mac) giggle (Linux) ( )
...!? Commit git commit --amend Stage Unstage git reset HEAD file git checkout -- file
Remote Server!! Branch Remote Branch master Remote origin git pull origin = git fetch origin + git merge origin/master Merge git push origin master Master Push Origin
"Remote" Protocol file:// ssh:// git:// http:// or https://
Branches
Commit git Commit
commit Commit Commit Snapshot Tree
branch commit
git branch testing "testing" branch git HEAD Branch
git checkout testing HEAD Testing Branch or git checkout -b testing Branch
Commit... testing master
git checkout master Master What's next?
git commit -m 'Change the master!'
Merge Rebase Push Rebase
Merge
Branch Bug hotfix branch master
git checkout master git merge hotfix master master hotfix Commit fast-foward
Branch Issue 53 branch Merge
git merge $ git checkout master $ git merge iss53 Merge made by recursive. README 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
CONFLICT git status git status git commit Merge Merge Commit Message
Rebase
Merge experiment branch?
git checkout experiment git rebase master C3 Rebase C4 (onto C4)
git checkout master git merge experiment Rebase fast-forward Merge
...
git rebase --onto master server client client Branch client server master
git checkout master git merge client client fast-forward Merge
git rebase master server Branch server Branch master
git checkout master git merge server git branch -d client git branch -d server Merge Branch :)
千萬不要 對已經Push的東西 作Rebase 除非你想成為害群之馬 Pic: http://commons.wikimedia.org/wiki/file:castle_romeo.jpg, Public Domain, United States Department of Energy
Remote Branches
Remote Branch Branch origin master origin/master git clone origin/master master
Remote Branch...
Pull = Fetch + Merge Origin Fetch Merge git pull git pull origin = git fetch origin git merge origin/master git merge origin/master b03ed
Remote
Fetch Remote Branch
Distributed Workflows
Commit/ Patch git diff --check Commit git add --patch Stage Commit Message
John 738ee Fetch Merge Push Jessica Branch Issue 54
Jessica Fetch Jessica John issue54 Fast-foward git checkout master git merge issue54 origin/master git merge origin/master Push
Branch Merge
A B Branch Rebase A Merge B
... Still a lot to learn!
github... Open Source
Pro Git http://progit.org/ Git ihower Git http://ihower.tw/blog/ archives/category/git