More Related Content Similar to Git and GitHub: A Concise Guide Similar to Git and GitHub: A Concise Guide (20) More from Wen-Tien Chang (20) Git and GitHub: A Concise Guide2. ?
• a.k.a. ihower
• http://ihower.tw
• http://twitter.com/ihower
• Ruby on Rails Developer since 2006
• The organizer of Ruby Taiwan Community
• http://ruby.tw 2
3. Agenda
‧1. DVCS
‧2. Git
‧3. Git
‧4. Github
‧5. Git
3
4. ‧2002 ( copy )
‧2005 SubVersion
‧2007 SVK
‧2008 Git ( SVN push/pull)
‧2009 Git ( master feature branches)
‧2011 Git ( git flow topic branch rebase)
4
15. Git
‧ Linux Torvalds (Linux creator)
‧ Linux Kernel
‧2005/4 2005/6 Linix
Kernel 2005/12 1.0
12
16. Git?
‧Git ‧Qt
‧Linux Kernel ‧Ruby on Rails
‧Perl ‧Android
‧Eclipse ‧PostgreSQL
‧Gnome ‧Debian
‧KDE ‧X.org
13
20. Git Way
metadata snapshots
I’m a mini filesystem!
Not just VCS.
Apple Time
Machine !
15
22. Why Git is Better than X
http://zh-tw.whygitisbetterthanx.com
‧
‧
‧Git
‧Git
‧Staging
‧
‧
‧ GitHub!
23. Git
SVN
‧svn merge
branch branch
‧svn log
‧svn commit checkout
commit
18
25. Install
‧ Git
http://help.github.com/set-up-git-redirect
‧ Git GUI(optional)
GitX (Mac)
TortoiseGit/Git Extensions (Windows)
qgit (Linux)
‧ SSH Key
ssh-keygen -t rsa -C "your_email@youremail.com"
20
26. Setup
‧ ~/.gitconfig
‧git config --global user.name "Your Name"
‧git config --global user.email "your@email.com"
‧git config --global color.ui true
‧git config --global core.editor "mate -w" (Textmate)
21
29. Repository
‧SSH
git clone git@github.com:ihower/sandbox.git
‧HTTP/HTTPS
git clone https://ihower@github.com/ihower/sandbox.git
‧ Git protocol ( )
git clone git://github.com/ihower/sandbox.git
‧File ( Dropbox git init --bare --shared !! Crazy!!)
git clone file://path/to/repo.git
24
31. ‧ README
‧git status
‧git diff
‧git add .
( !)
‧git status
‧git diff --cached
‧git commit -m “Update README”
26
32. Staging commit
‧touch a.rb
‧touch b.rb
‧git add a.rb
‧git commit “Update a”
‧git add b.rb
‧git commit “Update b”
27
33. ‧git rm a.rb
‧git mv b.rb c.rb
‧git add .
‧git commit “Remove a, Rename b to c”
‧ copy ? Git
cp
28
36. ‧ .gitignore ( commit )
‧ ~/.gitignore ( Global )
‧ commit
.gitkeep
‧.gitignore
https://github.com/github/gitignore
31
37. commit ?
‧tmp/*
‧log/*
‧ ( )
‧
‧build/* compile
‧.DS_Store
‧Thumbs.rb
32
38. Commit
‧ / /
bug fixed
unit test commit
commit
commit
‧git diff --check
‧commit
33
53. ‧Straight merge
branch commits
merge commit
Parents
fast-forward merge
commit --no-ff
45
54. (cont.)
‧Squashed commit
git merge new_feature --squash
merge-commit
log SVN merge
‧cherry-pick
git cherry-pick 714cba
commit
46
55. branch
‧ working tree branch
staging area modified
‧ commit push
reset
‧ stash
git stash
git stash apply
git stash clear
47
57. push branch
...
‧ SVN Git Commit
commit logs!!
commits
commit
commit commits
commits
49
58. reset ( commit )
‧git reset e37c75787
‧git reset HEAD^ ( working tree)
‧git reset HEAD^ --soft ( staging area)
‧git reset HEAD^ --hard ( )
50
59. revert ( commit )
‧ reset revert commit
‧git revert e37c75787
‧git revert HEAD^
51
60. rebase ( commit )
‧git rebase -i e37c7578
pick 048b59e first commit
pick 995dbb3 change something
pick aa3e16e changed
# Rebase 0072886..1b6475f onto 0072886
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
52
61. : rebase
‧rebase ( local branch)
1. branch
2. branch commits
apply/patch
commit log
local branch
53
62. : new_feature
master
D---E new_feature
/
A---B---C---F master
54
64. rebase G !
(new_feature) git rebase master
A---B---C---F---D'---E' new_feature
master
56
65. rebase G !
(new_feature) git rebase master
A---B---C---F---D'---E' new_feature
master
merge commit
56
66. push commits
push !!
57
67. rebase + merge
( feature branch develop)
‧
feature branch merge
feature branch typo commit
feature branch commits
‧
feature branch git rebase develop -i
( ) git rebase -i
develop branch git merge feature --no-ff
58
69. (1)
‧ --no-ff merge commit
fast-forward
‧rebase feature branch push
‧ feature branch
60
70. (2)
‧ rebase conflict
‧ rebase
branch rebase
61
74. GitHub?
‧twitter ‧jQuery
‧facebook ‧YUI 3
‧rackspace ‧mootools
‧digg ‧Ruby on Rails
‧Yahoo! ‧node.js
‧shopify ‧symfony
‧EMI ‧mongodb
‧six apart ‧Erlang
65
78. Patch ?
‧Fork Repository
‧Clone
‧Fix bugs Enhance features
‧Push
‧ Pull request
69
79. Fork & Pull Requests
75% fork outside merge !!
watch 25% outside contributions !!
70
84. Github pages
http://pages.github.com/
‧ your.github.com repository Github
http://your.github.com
‧ gh-pages your_project Github
http://your.github.com/your_project
75
85. Github pages
http://pages.github.com/
‧ your.github.com repository Github
http://your.github.com
‧ gh-pages your_project Github
http://your.github.com/your_project
Git
( Branch merge)
75
87. Push GitHub Reporitory
‧ Github
‧git remote add origin git@github.com:your_account/
sandbox.git
‧git push -u origin master
‧ git push
![rejected] git pull
77
91. git pull merge?
rebase?
‧ conflict merge
feature branch ?
‧ conflict
--rebase
80
92. git pull merge?
rebase?
‧ conflict merge
feature branch ?
‧ conflict
--rebase
git flow
branches
merge !
80
93. Git Submodule
‧Git SVN
‧ ? SVN Externals?
‧ http://josephjiang.com/entry.php?id=342
‧ ? http://josephjiang.com/entry.php?id=357
‧
Ruby/Rails Develops XD
Bundler dependencies
81
100. 2. Repository
Branches ?
88
101. Git flow: branches
http://nvie.com/posts/a-successful-git-branching-model/
http://ihower.tw/blog/archives/5140
89
102. ‧master: production-ready
‧develop:
90
108. git-flow
‧git flow init
‧git flow feature finish feature_name
‧git flow feature publish feature_name
‧git flow feature track feature_name
‧git flow feature finish feature_name
95
109. Branch-Owner Policy
‧ project leaders commit/merge
develop branch
‧ release team master branch
‧ topic branches pull
request code review
merge develop
‧GitHub pull request
96
112. the maintainer workflow for git itself
http://www.kernel.org/pub/software/scm/git/docs/gitworkflows.html
‧master tracks the commits that should go into
the next release
‧maint tracks the commits that should go into the
next "maintenance release"
‧next is intended as a testing branch for topics
being tested for stability for master.
‧pu (proposed updates branches) is an integration
branch for things that are not quite ready for
inclusion yet
‧topic branches for any nontrivial feature99
113. Ruby on Rails workflow
‧ Rails 3.0.5
‧master release 3.1
‧stable branches
2-2-stable
2-3-stable bug fixes
3-0-stable bug fixes
100
115. git-svn
‧ SubVersion
Git Git !
‧git svn clone http://url/svn/trunk/ project_name
‧(normal git operations)
‧git svn dcommit
102