Git and Github
for Startups
Daniel Gomes @danielcsgomes
July 13, 2013
workshop
Slide 2
Slide 2 text
• Full Stack Web Developer @ Sedimap PT
• Father, Geek
• Zend Certi!ed Engineer PHP 5.3
• Certi!ed Scrum Master
• @danielcsgomes
About Me
Slide 3
Slide 3 text
Agenda
Git
About Version Control
Basics of Git
A successful Git branching model
Github
About Github
Using Github
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
About Version Control
Slide 6
Slide 6 text
What is Version Control?
Version control is a system that records changes to
a file or set of files over time so that you can
recall specific versions later.
Slide 7
Slide 7 text
Types of
Version Control System
Local Version Control System
Centralized Version Control System (VCS)
Distributed Version Control System (DVCS)
Slide 8
Slide 8 text
Local
Version Control System
Slide 9
Slide 9 text
Centralized
Version Control System
Slide 10
Slide 10 text
Distributed
Version Control System
Slide 11
Slide 11 text
Basics of Git
Installing Git
First Git project
Basic Commands
Slide 12
Slide 12 text
Installing Git
First Git project
Basic Commands
Download
http:/
/git-scm.com/downloads
Slide 13
Slide 13 text
$ git config --global user.name "Your Name Here"
$ git config --global user.email "Your Email Here"
Add username and email to .gitconfig
Installing Git
First Git project
Basic Commands
Slide 14
Slide 14 text
Installing Git
First Git project
Basic Commands
# First Git Project
$ mkdir git_project
$ cd git_project
$ git init
$ tree -a -L 2
.
└── .git
├── HEAD
├── branches
├── config
├── description
├── hooks
├── info
├── objects
└── refs
Slide 15
Slide 15 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 16
Slide 16 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git init
Create an empty git repository
or reinitialize an existing one
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 17
Slide 17 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git add
Add file contents to the index
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 18
Slide 18 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git status
Show the working tree status
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 19
Slide 19 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git commit
Record changes to the repository
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 20
Slide 20 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git log
Show commit logs
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 21
Slide 21 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git diff
Show changes between commits,
commit and working tree, etc
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 22
Slide 22 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git branch
List, create, or delete branches
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 23
Slide 23 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git checkout
Checkout a branch or paths to the
working tree
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 24
Slide 24 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
git tag
Create, list, delete or verify a tag
object signed with GPG
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
Slide 25
Slide 25 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git pull
Fetch from and merge with another
repository or a local branch
Slide 26
Slide 26 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git fetch
Download objects and refs from
another repository
Slide 27
Slide 27 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git merge
Join two or more development
histories together
Slide 28
Slide 28 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git rebase
Forward-port local commits to the
updated upstream head
Slide 29
Slide 29 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git push
Update remote refs along with
associated objects
Slide 30
Slide 30 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git clone
Clone a repository into a new
directory
Slide 31
Slide 31 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git reset
Reset current HEAD to the
specified state
Slide 32
Slide 32 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git rm
Remove files from the working tree
and from the index
Slide 33
Slide 33 text
Installing Git
First Git project
Basic Commands
init
add
status
commit
log
diff
branch
checkout
tag
pull
fetch
merge
rebase
push
clone
reset
rm
submodule
git submodule
Submodules allow foreign repositories
to be embedded within a dedicated
subdirectory of the source tree,
always pointed at a particular commit.
Slide 34
Slide 34 text
A successful Git
branching model
http:/
/nvie.com/posts/a-successful-git-branching-model/
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
https:/
/github.com
Slide 37
Slide 37 text
What is Github?
Github is a powerful collaboration, code review, and
code management tool for open source and private
projects.
Slide 38
Slide 38 text
About Github
Founded in 2008
2013
more than 3 million users and 5 million
repositories
Free for Open Source projects
Slide 39
Slide 39 text
Using Github
Slide 40
Slide 40 text
Create an account
(demo)
https:/
/github.com/
Using Github
Slide 41
Slide 41 text
Set Up Git for Github
create the SSH key
Using Github
Slide 42
Slide 42 text
# generate the SSH Key
$ ssh-keygen -t rsa -C "[email protected]"
# Add your SSH key to Github
$ cat ~/.ssh/id_rsa.pub
# test if everything is working properly
$ ssh -T [email protected]
Create the SSH key
Using Github
Set Up Git for Github