starting with git & github
DESCRIPTION
Introduction to Git & GitHub. Agenda: - What’s a Version Control System? - What the heck is Git? - Some Git commands - What’s about GitHub? - Git in Action!TRANSCRIPT
![Page 1: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/1.jpg)
Nicolás Tourné @nicotourne
CTO of BeeReal
Tandil, Argentina - 2013
#BeeTalks
Starting with
Git & GitHub
![Page 2: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/2.jpg)
Agenda
• What’s a Version Control System?
• What the heck is Git?
• Some Git commands
• What’s about GitHub?
• Git in Action!
![Page 3: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/3.jpg)
What’s a Version Control System?
“An application that allows you to
record changes to your codebase in a
structured and controlled fashion.”
![Page 4: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/4.jpg)
Why do I need that?
• Makes it way easier to undo errors / roll
back to earlier versions of code
• Makes it way easier to share a codebase
between developers without creating
conflicts
• Makes it way easier to deploy changes
from development to staging or production
environments
![Page 5: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/5.jpg)
Popular Version Control Systems
• CVS - Concurrent Version System
• SVN - SubVersioN
• Git
• Mercurial
• Bazaar
• LibreSource
![Page 6: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/6.jpg)
What the heck is Git?
• Distributed Source Control system
• Open source, free (GNU GPL V2)
• Originally developed by Linus Torvalds for
the development of the Linux Kernel in 2005
• Focus on speed and efficiency
• Quite a unique design and therefore
sometimes a bit scary and difficult to
understand
![Page 7: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/7.jpg)
• Save snapshots, no differences
• Branching (lightweight & fast)
• Automatic merge of files
• Used on personal or very large projects, and
for all size of teams
What the heck is Git?
![Page 8: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/8.jpg)
Distributed Development
• Every Git working directory contains the
complete repository and history and full
revision tracking capabilities
• You’re not dependent on a central server
and you don’t have to be online
• It’s extremely fast - much faster than SVN,
CVS and other systems
![Page 9: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/9.jpg)
Centralized vs Distributed
Development
SVN / CVS - Centralized development
John
Central
Peter Bob Carl
![Page 10: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/10.jpg)
Git - Distributed development
Centralized vs Distributed
Development
John
Peter
Bob
Carl
Central
![Page 11: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/11.jpg)
A Git Sample
1. A new git is initialized as a remote
repository John Remote repository Peter
master
C0
![Page 12: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/12.jpg)
A Git Sample
2. John and Peter clone the git repository
John Remote repository Peter
master
C0
master
C0
master
C0
![Page 13: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/13.jpg)
A Git Sample
3. John does a commit
John Remote repository Peter
master
C1
master
C0
master
C0
C0
![Page 14: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/14.jpg)
A Git Sample
4. John does a push
John Remote repository Peter
master
C1
master
C0
C0
master
C1
C0
![Page 15: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/15.jpg)
A Git Sample
5. Peter does a pull
John Remote repository Peter
master
C1
master
C1
C0
master
C1
C0 C0
![Page 16: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/16.jpg)
A Git Sample
6. John does a commit & push
John Remote repository Peter
master
C2
master
C1
C1
master
C2
C0 C0
C0 C0
![Page 17: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/17.jpg)
A Git Sample
7. Peter does a commit
John Remote repository Peter
master
C2
master
C3
C1
master
C2
C1 C1
C0 C0 C0
![Page 18: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/18.jpg)
A Git Sample
8. Peter does a pull (fetch & merge)
John Remote repository Peter
master
C2
master
C2 C1
master
C2
C1
C1 C0 C0
C0
C3
C4
![Page 19: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/19.jpg)
A Git Sample
9. Peter does a push
John Remote repository Peter
master
C2
master
C2 C1
master
C4
C1 C0 C1
C0
C3
C4
C2 C3
C0
![Page 20: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/20.jpg)
A Git Sample
10. John does a pull
John Remote repository Peter
master
C4
master
C2
master
C4
C1 C1 C1
C0
C3
C4
C2 C3
C0
C2 C3
C0
![Page 21: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/21.jpg)
Git Commands
Getting and Creating projects
init
To create a git repository from an existing
directory of files
$ git init
clone
If you want to get a copy of a project, you
need to clone it
$ git clone [url]
![Page 22: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/22.jpg)
Git Commands
Basic Snapshotting
git add
You have to add file contents to your staging
area before you can commit them
$ git add index.php
git status
View the status of your files in the working
directory and staging area
$ git status
![Page 23: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/23.jpg)
Git Commands
Basic Snapshotting
git diff
Shows diff of what is staged and what is
modified but unstaged
$ git diff
git commit
Records a snapshot of the staging area
$ git commit -m “My comment”
![Page 24: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/24.jpg)
Git Commands
Basic Snapshotting
git reset
Undo changed and commits
$ git reset
git rm
Remove files from the staging area
$ git rm index.php
![Page 25: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/25.jpg)
Git Commands
Basic Snapshotting
git mv
Git doesn’t track file renames
$ git mv index.php index.html
git stash
Save changes made in the current index and
working directory for later
$ git stash
![Page 26: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/26.jpg)
Git Commands
Branching and Merging
git branch
List, create and manage branches
$ git branch
$ git branch QA
git checkout
Switch to a new branch context
$ git checkout QA
$ git checkout -b live
![Page 27: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/27.jpg)
Git Commands
Branching and Merging
git merge
Merge a branch context into your current one
$ git branch
$ git merge QA
git log
Show commit history of a branch
$ git log
![Page 28: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/28.jpg)
Git Commands
Branching and Merging
git tag
Tag a point in history as important
$ git tag -a v1.0
![Page 29: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/29.jpg)
Git Commands
Sharing and Updating Projects
git fetch
Download new branches and data from
remote repository
$ git fetch
git pull
Fetch from a remote repo and try to merge
into the current branch
$ git pull
![Page 30: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/30.jpg)
Git Commands
Sharing and Updating Projects
git push
Push your new branches and data to a remote
repository
$ git push
![Page 31: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/31.jpg)
What's about GitHub?
• It’s a Git repository hosting service… but it
adds many of its own features
• While Git is a command line tool, GitHub
provides a web-based graphical interface
• It also provides access control and several
collaboration features, such as wikis and
basic task management tools
![Page 32: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/32.jpg)
What's about GitHub?
• By default, all projects are public and free. In
you want a private project, then pay
• You can clone any public repository, follow
projects and developers, post comments, etc
• It’s becoming the Facebook’s for developers
![Page 33: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/33.jpg)
Git in Action!
Go to your computer and start playing...
1. Create a new repository on GitHub
2. Clone this repository
3. Add new files
4. Commit and push them
5. Create a new branch and merge files
![Page 34: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/34.jpg)
Thank you
for your attention!
Questions?
Just tweet me @nicotourne
or mail me at [email protected]
beerealit.com
![Page 35: Starting with Git & GitHub](https://reader037.vdocuments.us/reader037/viewer/2022100218/554a5619b4c905522f8b4c2a/html5/thumbnails/35.jpg)
More info at...
Official Git site
http://git-scm.com
Some slides
http://www.slideshare.net/jomikr/quick-introduction-to-git
http://www.slideshare.net/reallyordinary/intro-to-git-for-drupal-7
http://www.slideshare.net/anildigital/git-introduction
http://www.slideshare.net/chacon/getting-git
Git commands
http://gitref.org/basic
GitHub site
http://github.com