This document provides an overview of Git and GitHub. It discusses what Git is, how it works by storing content in trees and commits, and its advantages like efficiency and handling non-linear development. It also covers installing and configuring Git, including common settings. Key Git workflows like staging changes and committing are demonstrated. The document explains Git's three-tree model and inspection tools. It emphasizes the importance of branching in Git and how branches are cheap to create. Merging branches is shown to be powerful in Git.
10. Intelligence Check
Subversion is a smart database of file differences
Unfortunately, this makes it quite complex
Git is pretty stupid
11. Intelligence Check
Subversion is a smart database of file differences
Unfortunately, this makes it quite complex
Git is pretty stupid
Stores trees of content, much like a file system
12. Intelligence Check
Subversion is a smart database of file differences
Unfortunately, this makes it quite complex
Git is pretty stupid
Stores trees of content, much like a file system
A commit creates a new tree reachable by name
13. Intelligence Check
Subversion is a smart database of file differences
Unfortunately, this makes it quite complex
Git is pretty stupid
Stores trees of content, much like a file system
A commit creates a new tree reachable by name
It can change your directory to recreate any tree
16. Git Isn’t Really an SCM
Git does Source Code Management and
Peer to peer content distribution
17. Git Isn’t Really an SCM
Git does Source Code Management and
Peer to peer content distribution
Document database
18. Git Isn’t Really an SCM
Git does Source Code Management and
Peer to peer content distribution
Document database
Distributed wiki
19. Git Isn’t Really an SCM
Git does Source Code Management and
Peer to peer content distribution
Document database
Distributed wiki
Distributed issue tracker
20. Git Isn’t Really an SCM
Git does Source Code Management and
Peer to peer content distribution
Document database
Distributed wiki
Distributed issue tracker
Backups
22. The Plusses of
a Simple Design
It was designed to manage the development of the
Linux kernel (a very large code base)
23. The Plusses of
a Simple Design
It was designed to manage the development of the
Linux kernel (a very large code base)
Git is very efficient
24. The Plusses of
a Simple Design
It was designed to manage the development of the
Linux kernel (a very large code base)
Git is very efficient
Git handles non-linear development with grace
25. The Plusses of
a Simple Design
It was designed to manage the development of the
Linux kernel (a very large code base)
Git is very efficient
Git handles non-linear development with grace
Git is distributed from the ground up
32. The Minuses of
the Toolkit Design
Git provides a ton of commands to interact with it
33. The Minuses of
the Toolkit Design
Git provides a ton of commands to interact with it
The “porcelain” commands are the ones you
typically interact with
34. The Minuses of
the Toolkit Design
Git provides a ton of commands to interact with it
The “porcelain” commands are the ones you
typically interact with
The lower-level “plumbing” commands are crazy
powerful, but less user friendly
35. The Minuses of
the Toolkit Design
Git provides a ton of commands to interact with it
The “porcelain” commands are the ones you
typically interact with
The lower-level “plumbing” commands are crazy
powerful, but less user friendly
This can add up to make Git a little intimidating
43. THE INSTRUCTIONS I USE TO BUILD ON MAC OS X
THESE SIDESTEP THE DOCUMENTATION AND MACPORTS REQUIREMENTS
44. THE INSTRUCTIONS I USE TO BUILD ON MAC OS X
THESE SIDESTEP THE DOCUMENTATION AND MACPORTS REQUIREMENTS
45. Git is still young and
growing fast (update to 1.7)
46. [user]
name = James Edward Gray II
email = james@graysoftinc.com
[apply]
whitespace = nowarn
[color]
status = auto
branch = auto
interactive = auto
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gc]
auto = 1
[github]
user = JEG2
token = …
~/.GITCONFIG
THESE ARE SOME VERY HELPFUL GIT INTERFACE SETTINGS
47. [user]
name = James Edward Gray II
email = james@graysoftinc.com
[apply]
whitespace = nowarn
[color]
status = auto
branch = auto
interactive = auto
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gc]
auto = 1
[github]
user = JEG2
token = …
~/.GITCONFIG
THESE ARE SOME VERY HELPFUL GIT INTERFACE SETTINGS
48. [user]
name = James Edward Gray II
email = james@graysoftinc.com
[apply]
whitespace = nowarn
[color]
status = auto
branch = auto
interactive = auto
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gc]
auto = 1
[github]
user = JEG2
token = …
~/.GITCONFIG
THESE ARE SOME VERY HELPFUL GIT INTERFACE SETTINGS
49. [user]
name = James Edward Gray II
email = james@graysoftinc.com
[apply]
whitespace = nowarn
[color]
status = auto
branch = auto
interactive = auto
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gc]
auto = 1
[github]
user = JEG2
token = …
~/.GITCONFIG
THESE ARE SOME VERY HELPFUL GIT INTERFACE SETTINGS
50. set mainfont {Monaco 12}
set textfont {Monaco 12}
set uifont {"Monaco Bold" 12}
set tabstop 8
set findmergefiles 0
set maxgraphpct 50
set maxwidth 16
set cmitmode patch
set wrapcomment none
set showneartags 1
set showlocalchanges 1
set datetimeformat {%Y-%m-%d %H:%M:%S}
set limitdiffs 1
set bgcolor white
set fgcolor black
set colors {green red blue magenta darkgrey brown orange}
set diffcolors {red "#00a000" blue}
set diffcontext 3
set selectbgcolor gray85
set geometry(main) 794x484+5+45
set geometry(topwidth) 790
set geometry(topheight) 150
set geometry(pwsash0) "280 2"
set geometry(pwsash1) "420 2"
set geometry(botwidth) 350
set geometry(botheight) 314
set permviews {}
~/.GITK
THESE SETTINGS CLEAN UP THE INCLUDED GUI
51. # Git
alias g="git status"
alias ga="git add"
alias gaa="git add ."
alias gc="git commit -m"
alias gca="git commit -am"
alias gb="git branch"
alias gbd="git branch -d"
alias gco="git checkout"
alias gcob="git checkout -b"
alias gm="git merge"
alias gr="git rebase"
alias gl="git log"
alias gs="git show"
alias gd="git diff"
alias gbl="git blame"
alias gps="git push"
alias gpl="git pull"
~/.BASHRC
THESE ARE SOME BASH ALIASES I USE
52. # Git
alias g="git status"
alias ga="git add"
alias gaa="git add ."
alias gc="git commit -m"
alias gca="git commit -am"
alias gb="git branch"
alias gbd="git branch -d"
alias gco="git checkout"
alias gcob="git checkout -b"
alias gm="git merge"
alias gr="git rebase"
alias gl="git log"
alias gs="git show"
alias gd="git diff"
alias gbl="git blame"
alias gps="git push"
alias gpl="git pull"
~/.BASHRC
THESE ARE SOME BASH ALIASES I USE
53. # Git
alias g="git status"
alias ga="git add"
alias gaa="git add ."
alias gc="git commit -m"
alias gca="git commit -am"
alias gb="git branch"
alias gbd="git branch -d"
alias gco="git checkout"
alias gcob="git checkout -b"
alias gm="git merge"
alias gr="git rebase"
alias gl="git log"
alias gs="git show"
alias gd="git diff"
alias gbl="git blame"
alias gps="git push"
alias gpl="git pull"
~/.BASHRC
THESE ARE SOME BASH ALIASES I USE
55. Memorize all of That?
There’s a new trend to store your “dotfiles” online
56. Memorize all of That?
There’s a new trend to store your “dotfiles” online
This makes it easy to move them
57. Memorize all of That?
There’s a new trend to store your “dotfiles” online
This makes it easy to move them
Plus we can all share
58. Memorize all of That?
There’s a new trend to store your “dotfiles” online
This makes it easy to move them
Plus we can all share
Surprise: A great place to find these is GitHub
59. Memorize all of That?
There’s a new trend to store your “dotfiles” online
This makes it easy to move them
Plus we can all share
Surprise: A great place to find these is GitHub
Mine are at: http://github.com/JEG2/dotfiles
64. STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
65. GIT STATUS
GIT ADD .
GIT STATUS
GIT COMMIT -M “FIRST COMMIT.”
STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
66. GIT STATUS
GIT ADD .
GIT STATUS
GIT COMMIT -M “FIRST COMMIT.”
STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
67. GIT STATUS
GIT ADD .
GIT STATUS
GIT COMMIT -M “FIRST COMMIT.”
STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
68. GIT STATUS
GIT ADD .
GIT STATUS
GIT COMMIT -M “FIRST COMMIT.”
STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
69. GIT STATUS
GIT ADD .
GIT STATUS
GIT COMMIT -M “FIRST COMMIT.”
STAGING A CHANGE, THEN COMMITTING
THIS IS A NORMAL WORKFLOW FOR CHANGES IN GIT
70. GIT DATA IS SHARED BY THREE AREAS
THE REPOSITORY HOLDS ALL POSSIBLE WORKING DIRECTORIES
71. THE WORKING DIRECTORY
GIT DATA IS SHARED BY THREE AREAS
THE REPOSITORY HOLDS ALL POSSIBLE WORKING DIRECTORIES
72. THE INDEX
OR
STAGING AREA
GIT DATA IS SHARED BY THREE AREAS
THE REPOSITORY HOLDS ALL POSSIBLE WORKING DIRECTORIES
73. THE REPOSITORY
GIT DATA IS SHARED BY THREE AREAS
THE REPOSITORY HOLDS ALL POSSIBLE WORKING DIRECTORIES
74. GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
75. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
76. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
77. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
78. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
79. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
80. GIT LOG
GIT SHOW 96987
GIT SHOW 5F3F6
GIT BLAME README
GIT INCLUDES POWERFUL INSPECTION TOOLS
A SHA1 HASH (40 CHARACTERS) IS HOW GIT NAMES EVERYTHING
118. Git Trusts you With
the Scary Power Tools
Several Git commands can be used to revise the
commit history
119. Git Trusts you With
the Scary Power Tools
Several Git commands can be used to revise the
commit history
Total rewrites are possible
120. Git Trusts you With
the Scary Power Tools
Several Git commands can be used to revise the
commit history
Total rewrites are possible
Some consider this very evil
121. Git Trusts you With
the Scary Power Tools
Several Git commands can be used to revise the
commit history
Total rewrites are possible
Some consider this very evil
Let me show you two lighter uses that I consider
practical
122. YOU CAN AMEND (OR ADD TO) A COMMIT
THIS IS AWESOME PERFECT FOR WHEN YOU FORGET TO ADD A FILE
123. YOU CAN AMEND (OR ADD TO) A COMMIT
THIS IS AWESOME PERFECT FOR WHEN YOU FORGET TO ADD A FILE
124. YOU GET A CHANCE TO REVISE THE MESSAGE
AS YOU CAN SEE, I HAVE TEXTMATE SET AS MY EDITOR
125. THE TWO COMMITS BECAME ONE
NOTICE HOW ALL ASPECTS OF THE SECOND COMMIT WERE ROLLED INTO THE FIRST
126. THE TWO COMMITS BECAME ONE
NOTICE HOW ALL ASPECTS OF THE SECOND COMMIT WERE ROLLED INTO THE FIRST
127. GIT CAN “CHERRY PICK” COMMITS
YOU AREN’T REQUIRED TO TAKE COMMITS IN ORDER
128. GIT CAN “CHERRY PICK” COMMITS
YOU AREN’T REQUIRED TO TAKE COMMITS IN ORDER
129. GIT CAN “CHERRY PICK” COMMITS
YOU AREN’T REQUIRED TO TAKE COMMITS IN ORDER
136. Git Ships With
Subversion Support
Checkout with: git svn clone SUBVERSION_URL
Add --username=USER if needed
137. Git Ships With
Subversion Support
Checkout with: git svn clone SUBVERSION_URL
Add --username=USER if needed
Update with: git svn rebase
138. Git Ships With
Subversion Support
Checkout with: git svn clone SUBVERSION_URL
Add --username=USER if needed
Update with: git svn rebase
Subversion requires a linear history, thus rebase
139. Git Ships With
Subversion Support
Checkout with: git svn clone SUBVERSION_URL
Add --username=USER if needed
Update with: git svn rebase
Subversion requires a linear history, thus rebase
Use Git to develop locally as normal
140. Git Ships With
Subversion Support
Checkout with: git svn clone SUBVERSION_URL
Add --username=USER if needed
Update with: git svn rebase
Subversion requires a linear history, thus rebase
Use Git to develop locally as normal
Commit all diffs to Subversion: git svn dcommit
148. To Set That Up…
I created a git_server directory on my Desktop
149. To Set That Up…
I created a git_server directory on my Desktop
I moved my faster_csv repository into it
150. To Set That Up…
I created a git_server directory on my Desktop
I moved my faster_csv repository into it
I ran: git daemon --base-path=/Users/james/
Desktop/git_server --export-all
151. To Set That Up…
I created a git_server directory on my Desktop
I moved my faster_csv repository into it
I ran: git daemon --base-path=/Users/james/
Desktop/git_server --export-all
This is read-only (but write support is possible)
access on port 9418
152. To Set That Up…
I created a git_server directory on my Desktop
I moved my faster_csv repository into it
I ran: git daemon --base-path=/Users/james/
Desktop/git_server --export-all
This is read-only (but write support is possible)
access on port 9418
This rocks for when GitHub is down
158. An Instant
Web Interface
I moved into the Git working directory
I ran: git instaweb --httpd=webrick
Later, I will stop it with: git instaweb --stop
159. An Instant
Web Interface
I moved into the Git working directory
I ran: git instaweb --httpd=webrick
Later, I will stop it with: git instaweb --stop
This is a handy poor man’s repository browser
that’s pretty much always available
169. Git Supports
Many Work Styles
Git’s features make it very flexible
Non-linear history is fully supported
170. Git Supports
Many Work Styles
Git’s features make it very flexible
Non-linear history is fully supported
Powerful history rewriting is provided
171. Git Supports
Many Work Styles
Git’s features make it very flexible
Non-linear history is fully supported
Powerful history rewriting is provided
All repositories are masters
172. Git Supports
Many Work Styles
Git’s features make it very flexible
Non-linear history is fully supported
Powerful history rewriting is provided
All repositories are masters
Any repository can be distributed
173. Git Supports
Many Work Styles
Git’s features make it very flexible
Non-linear history is fully supported
Powerful history rewriting is provided
All repositories are masters
Any repository can be distributed
Many work strategies are built off of these features
269. Supported Formats
RDoc (.rdoc)
Reuse your Ruby project documentation
Markdown (.markdown, .md, .mdown, …)
A human-readable format for other projects
270. Supported Formats
RDoc (.rdoc)
Reuse your Ruby project documentation
Markdown (.markdown, .md, .mdown, …)
A human-readable format for other projects
Also supported: Textile (.textile), PNG (.png),
reStructuredText (.rst), and POD (.pod)
279. GitHub Pages
Name a repository after you: USER.github.com
Or add a gh-pages branch to any repository
280. GitHub Pages
Name a repository after you: USER.github.com
Or add a gh-pages branch to any repository
GitHub will build the site after each commit
281. GitHub Pages
Name a repository after you: USER.github.com
Or add a gh-pages branch to any repository
GitHub will build the site after each commit
Sites are Jekyll (a static site generator) processed
282. GitHub Pages
Name a repository after you: USER.github.com
Or add a gh-pages branch to any repository
GitHub will build the site after each commit
Sites are Jekyll (a static site generator) processed
Used to build listings, syntax highlight, etc.
283. GitHub Pages
Name a repository after you: USER.github.com
Or add a gh-pages branch to any repository
GitHub will build the site after each commit
Sites are Jekyll (a static site generator) processed
Used to build listings, syntax highlight, etc.
You can point a real domain at them
290. Where to Find the Docs
Git has awesome man(ual) pages
291. Where to Find the Docs
Git has awesome man(ual) pages
Replace spaces with dashes: man git-stash
292. Where to Find the Docs
Git has awesome man(ual) pages
Replace spaces with dashes: man git-stash
Scott Chacon’s (GitHub’s Git Guru) Pro Git book
293. Where to Find the Docs
Git has awesome man(ual) pages
Replace spaces with dashes: man git-stash
Scott Chacon’s (GitHub’s Git Guru) Pro Git book
Free online: http://progit.org/
294. Where to Find the Docs
Git has awesome man(ual) pages
Replace spaces with dashes: man git-stash
Scott Chacon’s (GitHub’s Git Guru) Pro Git book
Free online: http://progit.org/
GitHub has good guides: http://help.github.com/
295. Where to Find the Docs
Git has awesome man(ual) pages
Replace spaces with dashes: man git-stash
Scott Chacon’s (GitHub’s Git Guru) Pro Git book
Free online: http://progit.org/
GitHub has good guides: http://help.github.com/
They cover GitHub and Git topics