The Basics of Open Source Collaboration With Git and GitHub

40
Open Source Collaboration with Git and GitHub by Benjamin Young adapted from work by Nick Quaranto

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 of The Basics of Open Source Collaboration With Git and GitHub

Page 1: The Basics of Open Source Collaboration With Git and GitHub

Open Source Collaboration with Git and GitHub

by Benjamin Youngadapted from work by

Nick Quaranto

Page 2: The Basics of Open Source Collaboration With Git and GitHub

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

Page 3: The Basics of Open Source Collaboration With Git and GitHub

Ve rs ion Control c ould s a v e your

life .

Page 4: The Basics of Open Source Collaboration With Git and GitHub

Or a t le a s t your job/proje c t/ide a /

s a nity /gpa

Page 5: The Basics of Open Source Collaboration With Git and GitHub

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

Page 6: The Basics of Open Source Collaboration With Git and GitHub
Page 7: The Basics of Open Source Collaboration With Git and GitHub
Page 8: The Basics of Open Source Collaboration With Git and GitHub

Directed Acyclic Graph

Page 9: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Blobs

457aef 93f f 7f f bb289f 7e1384f 900679eacf 044a

main.c

Page 10: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Trees

Page 11: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Commits

Page 12: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Commits

Page 13: The Basics of Open Source Collaboration With Git and GitHub

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

Page 14: The Basics of Open Source Collaboration With Git and GitHub

The Staging Area

Page 15: The Basics of Open Source Collaboration With Git and GitHub

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

#

Page 16: The Basics of Open Source Collaboration With Git and GitHub

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';

+?>

Page 17: The Basics of Open Source Collaboration With Git and GitHub

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

Page 18: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Branches

branchname

HEAD

Page 19: The Basics of Open Source Collaboration With Git and GitHub

Branching

Page 20: The Basics of Open Source Collaboration With Git and GitHub

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

Page 21: The Basics of Open Source Collaboration With Git and GitHub

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

Page 22: The Basics of Open Source Collaboration With Git and GitHub

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?

Page 23: The Basics of Open Source Collaboration With Git and GitHub

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

Page 24: The Basics of Open Source Collaboration With Git and GitHub

Git Internals: Remotes

branchname

HEAD

remotes/server/name

Page 25: The Basics of Open Source Collaboration With Git and GitHub

Local vs. Remote

Page 26: The Basics of Open Source Collaboration With Git and GitHub

Multiple Workflows

Page 27: The Basics of Open Source Collaboration With Git and GitHub

Centralized

Page 28: The Basics of Open Source Collaboration With Git and GitHub

Integration Manager

Page 29: The Basics of Open Source Collaboration With Git and GitHub

Benevolent Dictator

Page 30: The Basics of Open Source Collaboration With Git and GitHub

Where to Share

Page 31: The Basics of Open Source Collaboration With Git and GitHub
Page 32: The Basics of Open Source Collaboration With Git and GitHub

=

Page 33: The Basics of Open Source Collaboration With Git and GitHub
Page 34: The Basics of Open Source Collaboration With Git and GitHub
Page 35: The Basics of Open Source Collaboration With Git and GitHub
Page 36: The Basics of Open Source Collaboration With Git and GitHub
Page 37: The Basics of Open Source Collaboration With Git and GitHub
Page 38: The Basics of Open Source Collaboration With Git and GitHub

Other Hosting Options

• Public Only– repo.or.cz– Gitorious.org

• Private Only– Unfuddle.com– codebasehq.com

• Public and Private– GitHub.com– CodaSet.com

Page 39: The Basics of Open Source Collaboration With Git and GitHub

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!!

Page 40: The Basics of Open Source Collaboration With Git and GitHub

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