the basics of open source collaboration with git and github
DESCRIPTION
A revised/minimized version of Nick Quaranto's (http://www.slideshare.net/qrush ) presentation on the same topic. This revised version was used to present Git to a group of students at ECPI who were not yet familiar with the concepts of version control or Git.TRANSCRIPT
Open Source Collaboration with Git and GitHub
by Benjamin Youngadapted from work by
Nick Quaranto
whoami
• President of BigBlueHat– a web manufacturing company– we build web stuff
• We built BlueInk– a content management system
• Building sites since the late 90's– I remember Netscape 3
Ve rs ion Control c ould s a v e your
life .
Or a t le a s t your job/proje c t/ide a /
s a nity /gpa
The Basics
• Keep “backup” copies of files whenever you want
• Restore those copies quickly and easily• Share the files and the change s with other
developers• Integrate their changes into your files
Directed Acyclic Graph
Git Internals: Blobs
457aef 93f f 7f f bb289f 7e1384f 900679eacf 044a
main.c
Git Internals: Trees
Git Internals: Commits
Git Internals: Commits
Giting Started
• mkdir new_proj• cd new_proj• git init• ...do some work...• git add .• git commit
• cd old_proj• git init• git add .• git commit
The Staging Area
What's changed?
git statusOn branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: index.php
#
What's changed? (cont)
git diffdiff --git a/index.php b/index.php
index 9e7353c..1764d3e 100644
--- a/index.php
+++ b/index.php
@@ -24,4 +24,5 @@
require_once 'webroot'.DIRECTORY_SEPARATOR.'index.php';
-?>
\ No newline at end of file
+echo 'an example change';
+?>
Birds Eye View
• git log• gitk
– a graphical view of your repository• GitX
– Mac OS X app for doing the above– also handy for commit review– prettier than gitk
Git Internals: Branches
branchname
HEAD
Branching
Branching
• Another great reason to use Version Control—particularly git
• “Your first idea is never your best idea”• Branches give you the freedom to change
things...whenever
Branching (cont)
• git branch experimental– creates a branch named 'experimental'
• git branch– shows a list of branches:
• git checkout experimental– switch to the new branch
The Staging Area (cont)
• All that happened in the same directory– sort of...
• Your version histories actually in the .git folder
• so, when you checkout a branch git changes all the files outside of .git to match that branches content
• git it?
Put it back together again
• git checkout master• git merge experimental
• if all went well, then your done• if not:
• git mergetool• git commit -a
Git Internals: Remotes
branchname
HEAD
remotes/server/name
Local vs. Remote
Multiple Workflows
Centralized
Integration Manager
Benevolent Dictator
Where to Share
=
Other Hosting Options
• Public Only– repo.or.cz– Gitorious.org
• Private Only– Unfuddle.com– codebasehq.com
• Public and Private– GitHub.com– CodaSet.com
How to Contribute
1. Fork a repository at GitHub 2. Clone and connect your local repository 3. Write tests, implement functionality4. Commit your local changes 5. Push your changes to your fork6. Make a pull request7. Profit!!
git log• Kudos to Sc ott Cha c on who made
– http://git-scm.com– http://whygitisbetterthanx.com
• And to Mic ha e l Ha rtl– for Building the Insoshi Social Network
• Wikipedia too.
[email protected]://litanyagainstfear.com
[email protected]://bigbluehat.com