Working with Git – a simple introduction for those used to working with a VCS like Subversion. Explains concepts and shows examples. Feel free to steal slides for your own purposes.
18. EVERYTHING IS LOCAL
Everything is stored in a “.git” directory at the root of your
project
Commits are local
Branches are local
You don’t check out the latest revision – you clone the
whole repository
19. Pros Cons
Work offline
Carry your repository on a
flash drive
Work on experimental
branches without cluttering
A big repository means a large
up other people’s repositories
initial download
Share when you’re ready
No more waiting in line
Easy to set up, no server to
run
30. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
31. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
32. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
git add
33. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
git add
34. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
35. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
git commit
36. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
git commit
37. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
git commit
38. Working Copy Staging Area Commit
(Your Project) (Preparing the commit)
39. Chapter I
Genesis
In the beginning was the word, and
the word was Bob, who accepted all
forms of credit card, yea, even
Discover.
# Saved ‘chapter1.txt’
40. $ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to
include in what will be committed)
#
# chapter1.txt
41. $ git add chapter1.txt
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..."
to unstage)
#
# new file: chapter1.txt
#
42. $ git commit -m “Added the first
chapter.”
[master (root-commit) 8621aee] Added
the first chapter.
1 files changed, 1 insertions(+), 0
deletions(-)
create mode 100644 chapter1.txt
43. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
44. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
45. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
46. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
47. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
48. $ git log
commit f9ac73d56d3852d1878a4d8a2309ecfda4472e84
Author: Pete Nicholls <pete@metanation.com>
Date: Sat Apr 9 16:31:28 2011 +1200
Added delimiter to points.
diff --git a/app/helpers/application_helper.rb b/app/helpers/
application_helper.rb
index 37d4a59..c442368 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
end
def plain_points(points)
- "#{points} points"
+ "#{number_with_delimiter points} points"
end
def link_to_with_count(text, link = nil, count = 0, options = {})
57. $ git clone
git://tomeofsecrets/holybook.git
$ cd holybook
58. Chapter II
Tim the Enchanter
Bob said unto Tim, “Yea, and we will
make so much money.” And Tim saw that
it was good, or at least better than
his usual Saturday nights out.
# Saved ‘chapter2.txt’
59. $ git add chapter2.txt
$ git commit -m “Added the second
chapter.”
$ git push origin master
$ git pull origin master
$ ls
chapter1.txt chapter2.txt
60. $ git commit -m “Added the bit with
the killer rabbit.”
$ git commit -m “Added the bit with
the bridge crossing.”
$ git commit -m “Proper coconut use.”
$ git commit -m “Added smiting.”
$ git commit -m “Turned peasant into
a mustard pot.”
$ git commit -m “Extra smiting.”
72. msygit
Git for the command-line.
http://git-scm.com
TortoiseGit
File browser and contextual
menu integration, port of
TortoiseSVN.
http://code.google.com/p/tortoisegit
Cygwin
Linux environment for
Windows. Git available
through package manager.
http://cygwin.com
I&#x2019;m not a Git expert, just a happy user for the last three years. Before that, I used Subversion.\n
Created in 2005 by Linus Torvalds to work on the Linux kernel\nBuilt around the concepts of distributed version control and non-linear development\n
\n
What do we mean by &#x201C;distributed&#x201D;? Let&#x2019;s take a look at an example using Subversion.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
Person A makes commits his changes to the Subversion server. Person B updates their working copy from the server.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
In the Git world, there is no central server. Repositories live locally on a person&#x2019;s hard drive. There are no revision numbers &#x2013; instead there&#x2019;s a hash representing each commit. One person can pull from another person&#x2019;s repository into their own. They don&#x2019;t need to pull all changes.\n
There is no one copy. Different people can merge and track other people&#x2019;s branches. The result is it&#x2019;s possible for different development workflows than &#x201C;one linear log of work.&#x201D; Having said that...\n
...in most projects, you will have a central, canonical repository, because it&#x2019;s convenient. But you don&#x2019;t have to share all your branches and commits with it. [Compare Subversion/trunk Git/master]\n
Everything in git is local.\n
\n
\n
Git is a collection of tools. Git works well by itself, but it plays better with friends. It&#x2019;s designed to work as part of an ecosystem of development. It knows that version control is just a tool, that&#x2019;s part of your workflow as a developer. It stresses flexibility, speed, and integration with your workflow. [Prune large files, branch/merge speeds, Git hooks as example]\n
One of the things you&#x2019;ll hear quite often. It refers to the method and speed that Git handles branches. When a branch takes a half second to create and incurs no file size penalty, it&#x2019;s trivial to create them. When you don&#x2019;t have to share them, you don&#x2019;t need to worry about making too many branches. It&#x2019;s also easy to branch from a branch, which is common.\n
Simple example workflow. Nothing earth-shattering.\n
Meet Bob.\n
\n
Bob has an ambition.\n
He wants to start his own religion.\n
The Church of Bob\n
\n
He starts by writing his holy book. [Explain git init]\nNext: Working copy/staging area\n
[Explain concepts]\nLet&#x2019;s say we change a file...\n
\n
We use git add to move it into the staging area. \n
\n
Once in the area [explain about how making changes won&#x2019;t affect the staging area&#x2019;s version]\n
\n
Git commit will save the changes in the staging area along with a commit message.\n
\n
Let&#x2019;s go back to Bob, who&#x2019;s written his first chapter of the Book of Bob.\n
He&#x2019;s saved the file as &#x2018;chapter1.txt&#x2019;\nNext: git status\n