intro to git and github

31
An intro to Git and GitHub Drupal will be soon hosted at GiHub but before that learn Git for your own good and sanity Panagiotis Papadopoulos 6pna / Sfalma @panosjee DrupalCamp, Athens, 12 December 2010

Upload: panagiotis-papadopoulos

Post on 29-Nov-2014

3.135 views

Category:

Documents


3 download

DESCRIPTION

Preso about Git and Github at DrupalCamp Athens 2010

TRANSCRIPT

Page 1: Intro to Git and GitHub

An intro to Git and GitHub

Drupal will be soon hosted at GiHub but before that learn Git for your own good and sanity

Panagiotis Papadopoulos6pna / Sfalma@panosjee

DrupalCamp, Athens, 12 December 2010

Page 2: Intro to Git and GitHub

Who am I?Freelancer and startuper wannabe. Athens Ruby and GTUG organiser.Not a guru in something. Man of all trades master to none with an inclination towards Ruby, Python, Javascript.Do not ask me Drupal, but I will help drupalists with www.sfalma.com (shameless promo)

Page 3: Intro to Git and GitHub

Subversion is the most pointless project ever started

Linus Torvalds

Page 4: Intro to Git and GitHub

What is Git?

Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development.

Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

Git's current software maintenance is overseen by Junio Hamano. Git is free software distributed under the terms of the GNU General Public License version 2.

If Git is a heavenly tool, GitHub is a programmer 's heaven.

- PanosJee, December 12th 2010

Source: http://en.wikipedia.org/wiki/Git_(software)

Page 5: Intro to Git and GitHub

Git is distributed

panosjee jonromero

doxarassavvas

Page 6: Intro to Git and GitHub

Git is a very simple beast!

Git is:DistributedNon linear developmentEfficient

very small footprintConsists of Git objects which are the actual data of Git, the main thing that the repository is made up of.The four main objects of Git are blobs, trees, commits and tags.

A Git object is a file in the repository compressed (with Zlib) and referenced by the SHA-1 value of its contents plus a small header. The contents of a file are stored as blobs.

Page 7: Intro to Git and GitHub

The Git model (1)

A simple repo with the following structure:

- module - init.php -- includes - definitions.php -- lib - model.php

Example from the excellent http://peepcode.com/products/git-internals-pdf

Commands$ git init .$ git add .$ git commit -m "first commit"

Page 8: Intro to Git and GitHub

The Git model (2)

A simple repo with the following structure:

- module - init.php -- includes - definitions.php -- lib - model.php -- validators - email.php

Example from the excellent http://peepcode.com/products/git-internals-pdf

Commands$ git tag "first tag"$ mkdir validators$ touch email.php$ git add .$ git commit -m "added validators"

Page 9: Intro to Git and GitHub

The Git model (3)A simple repo with the following structure:

- module - init.php -- includes - definitions.php -- lib - model.php * -- validators - email.php

Example from the excellent http://peepcode.com/products/git-internals-pdf

Commands$ vim model.php$ git add .$ git commit -m "include validators"

Page 10: Intro to Git and GitHub

The Git model (4)A simple repo with the following structure:

- module - init.php -- includes - definitions.php -- lib - model.php -- validators - email.php

Example from the excellent http://peepcode.com/products/git-internals-pdf

Page 11: Intro to Git and GitHub

Git is snapshot based

1 2

Multiple parents

1

Easy branching

2 3

4

$ git commit -m "new commit"

$ git commit -m "new commit"$ git branch 4

Page 12: Intro to Git and GitHub

Git is snapshot based

12

1

Easy merging

2 35

master

4$ git merge 4

Page 13: Intro to Git and GitHub

The virtues of GitFork, Clone, Pull, Remote

Page 14: Intro to Git and GitHub

Git pull. Full control. Remote repos.

Made for speed, full visibility in a few lines.You can pull from 1-n remote repos. As we said Git is

distributed.

Page 15: Intro to Git and GitHub

Know thy status

What 's untracked. What 's modified. What 's added. What 's deleted. What 's changed.

Page 16: Intro to Git and GitHub

Git branches carry their historyOnce you clone a Git repo you have complete access to all previous versions. For ever.

Page 17: Intro to Git and GitHub

Git stash

Real life scenario.

You are working on your code and your colleagues just pushed a very important fix that you needed.

You cannot pull changes if you have not commited your code, but you should not commit as you are still experimenting.

What do you do ?

Just put your changes aside (git stash) get your friends changes (git pull) and then apply your changes that you had pust aside (git stash apply).

Neat?

Page 18: Intro to Git and GitHub

Commit to Open Source in a breeze

The distributed nature of Git means you can work locally on code and push to a remote repository when ready.

This is perfect for teams and Open Source projects.

The procedure is simple:1. Find an open source project2. Fork it3. Clone (download locally)4. Do your changes 5. Push to your remote

Wanna have your changes merged into initial repo?

1. Do a pull request2. Hope the author accepts it

Page 19: Intro to Git and GitHub
Page 21: Intro to Git and GitHub

Tower - Mac App - Still beta - Impressive

Page 22: Intro to Git and GitHub

GitX for Mac - GitK for other platforms

Page 23: Intro to Git and GitHub

GitWeb - Web UI - Shipped with Git

Page 24: Intro to Git and GitHub

Giggle - Linux

Page 25: Intro to Git and GitHub
Page 26: Intro to Git and GitHub

GitHub is the Facebook of Code

GitHub is an unparallel tool that offers you unlimited public repos and private repos on subscriptions plans.

Github is:1. Collaboration tool2. Code host3. Wiki4. Issue tracker5. Code review tool6. Git UI7. Social

I am always struck by the wealth of project I find on GitHub. Lots of major open source projects are there for you to use and study.Fork them, change them, contribute in no time.

If you are a coder and you have never used GitHub you probably live in a parallel universe :P

Page 27: Intro to Git and GitHub
Page 28: Intro to Git and GitHub
Page 29: Intro to Git and GitHub
Page 30: Intro to Git and GitHub

GitHub Network Graph Viewer

Page 31: Intro to Git and GitHub

Questions?You may also use Mercurial, Fossil, Bazaar but

Mercurial and Git are the winners :P

http://bit.ly/git-dcath