SlideShare a Scribd company logo
Git and Github Basics
      http://git-scm.com
Why Git?
Why Git?


Distributed Repositories
Why Git?


Distributed Repositories

Easy Merging
Why Git?


Distributed Repositories

Easy Merging

No File Locks
Starting From Scratch?
Starting From Scratch?


new_project patrick$ git init
Initialized empty Git repository in /Users/patrick/gittalk/
new_project/.git/
Existing Repository?
Existing Repository?


patrick$ git clone git@github.com:thelearninghouse/
request-forms.git <location>
Committing a change

patrick$ echo "Initial README" > README
patrick$ git add README
patrick$ git commit -m "Added README"
[master (root-commit) 5008efe] Added README
 1 file changed, 1 insertion(+)
 create mode 100644 README
What Happened?
What Happened?

patrick$ git log
commit 5008efe3eab3e746f1d54214566c6b3ed79d3656
Author: Patrick Tinsley <prtinsley@gmail.com>
Date:   Thu Oct 25 21:31:17 2012 -0400

    Added README
How Git Works
 Working Directory
               git add

     Staging
               git commit


    Repository
Workflow

Code

Stage your changes (git add)

Review your work (git status, git diff)

Commit (locally) (git commit)

Repeat
Un-Staged Changes
Un-Staged Changes
patrick$ echo “I’m updating this again.” > README
Un-Staged Changes
patrick$ echo “I’m updating this again.” > README


patrick$ git status
# On branch master
# Changes not staged for commit:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in
working directory)
#
#	 modified:    README
#
no changes added to commit (use "git add" and/or "git commit -a")
Staged Changes
Staged Changes
patrick$ git add .
Staged Changes
patrick$ git add .


patrick$ git status
# On branch master
# Changes to be committed:
#    (use "git reset HEAD <file>..." to unstage)
#
#	 modified:    README
#
Reset
Reset
patrick$ git reset
Unstaged changes after reset:
M	 README
Reset
patrick$ git reset
Unstaged changes after reset:
M	 README


patrick$ git status
# On branch master
# Changes not staged for commit:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in working
directory)
#
#	 modified:    README
#
no changes added to commit (use "git add" and/or "git commit -a")
Hard Reset
Hard Reset
patrick$ git reset --hard HEAD
HEAD is now at e502220 Test update
Why Branch?
Why Branch?


Safely experiment with new ideas
Why Branch?


Safely experiment with new ideas

Agility
Why Branch?


Safely experiment with new ideas

Agility

Git makes branching easy
Why Branch?


Safely experiment with new ideas

Agility

Git makes branching easy

Git makes merging (usually...) very easy
Branch and Merge

c5    c4   c3   c2   c1   master


           c2   c1    new_feature
How Do We Do It?
How Do We Do It?
patrick$ git checkout -b new_feature
Switched to a new branch 'new_feature'
How Do We Do It?
patrick$ git checkout -b new_feature
Switched to a new branch 'new_feature'


patrick$ git branch
  master
* new_feature
How Do We Do It?
patrick$ git checkout -b new_feature
Switched to a new branch 'new_feature'


patrick$ git branch
  master
* new_feature


patrick$ git checkout master
Switched to branch 'master'
How Do We Do It?
patrick$ git checkout -b new_feature
Switched to a new branch 'new_feature'


patrick$ git branch
  master
* new_feature


patrick$ git checkout master
Switched to branch 'master'


patrick$ git branch -d new_feature
Deleted branch new_feature (was
5008efe).
What About Merging?
What About Merging?

patrick$ git checkout master
Switched to branch 'master'
What About Merging?

patrick$ git checkout master
Switched to branch 'master'



patrick$ git merge update_readme
Updating 01ba47f..ee04cb3
Fast-forward
 README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Conflict!
Conflict!

patrick$ git merge update_readme
Auto-merging README
CONFLICT (content): Merge conflict in README
Automatic merge failed; fix conflicts and then commit the result.
What Happened?
What Happened?

patrick$ git status
# On branch master
# Unmerged paths:
#    (use "git add/rm <file>..." as appropriate to mark
resolution)
#
#	 both modified:       README
#
no changes added to commit (use "git add" and/or "git commit -a")
Resolve and Commit
Remote Repositories
Github.com

Another copy, much like yours

Backup

Collaborate

Distribute

Service Hooks
Working With Github
Working With Github


Update your knowledge of Github (git fetch)
Working With Github


Update your knowledge of Github (git fetch)

Update your local copy (git pull)
Working With Github


Update your knowledge of Github (git fetch)

Update your local copy (git pull)

Push your code to Github (git push)
Example
Example
example_app patrick$ git pull origin master
From github.com:prtinsley/example_app
 * branch            master     -> FETCH_HEAD
Already up-to-date.
Example
example_app patrick$ git pull origin master
From github.com:prtinsley/example_app
 * branch            master     -> FETCH_HEAD
Already up-to-date.


example_app patrick$ git push origin master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 300 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@github.com:prtinsley/first_app.git
   261f716..8b66dca master -> master
Stashing
Stashing

Cannot change branches with pending
changes

Save your work if not ready to commit

Apply pending changes to a different branch

Works like a stack
Example
Example
patrick$ git status
# On branch master
# Changes not staged for commit:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in working
directory)
#
#	 modified:    README
Example
patrick$ git status
# On branch master
# Changes not staged for commit:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in working
directory)
#
#	 modified:    README



patrick$ git stash
Saved working directory and index state WIP on master: 92a5183
Updated README
HEAD is now at 92a5183 Updated README
Example
Example
patrick$ git status
# On branch master
nothing to commit (working directory clean)
Example
patrick$ git status
# On branch master
nothing to commit (working directory clean)




patrick$ git stash apply
# On branch master
# Changes not staged for commit:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in
working directory)
#
#	 modified:    README
#
Deployments


Code pulled from repository or build archive

Code not checked in will be overwritten

Soon all production servers will be IT access
only
Resources

http://help.github.com

http://git-scm.com/book

  Definitive guide written by a Github dev

http://net.tutsplus.com/tutorials/other/easy-
version-control-with-git/

  Much more basic
GUI Clients
Tower

  http://www.git-tower.com/

SourceTree

  http://www.sourcetreeapp.com/

Github for Mac

  http://mac.github.com/
Questions?
Github
http://github.com
Context
Activity Feed
Main Repository Page
Clone URL
Branches
Commit History
Commit History
Change Sets
Excellent Help Docs



http://help.git.com
Questions?
Slides Available

More Related Content

PDF
Git - Get Ready To Use It
PDF
My Notes from https://www.codeschool.com/courses/git-real
PDF
PDF
Git Real
PPTX
Introduction To Git Workshop
PDF
Version Control with Git for Beginners
DOCX
Git github
KEY
Git Distributed Version Control System
Git - Get Ready To Use It
My Notes from https://www.codeschool.com/courses/git-real
Git Real
Introduction To Git Workshop
Version Control with Git for Beginners
Git github
Git Distributed Version Control System

What's hot (20)

PDF
Git real slides
PPT
Learn Git Basics
PDF
Git Basics (Professionals)
PPTX
PDF
Undoing Things in Git
PDF
Git internals
PDF
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
KEY
The everyday developer's guide to version control with Git
PDF
GIT - GOOD PRACTICES
KEY
Git Acquainted
PPTX
PDF
Git: basic to advanced
PPTX
GIT in a nutshell
KEY
Git Basics at Rails Underground
PPTX
Git for beginner
PDF
Git in a nutshell
PDF
Intro to Git and GitHub
KEY
Matt Gauger - Git & Github web414 December 2010
PDF
Introduction to Git
PPTX
Git and GitHub
Git real slides
Learn Git Basics
Git Basics (Professionals)
Undoing Things in Git
Git internals
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
The everyday developer's guide to version control with Git
GIT - GOOD PRACTICES
Git Acquainted
Git: basic to advanced
GIT in a nutshell
Git Basics at Rails Underground
Git for beginner
Git in a nutshell
Intro to Git and GitHub
Matt Gauger - Git & Github web414 December 2010
Introduction to Git
Git and GitHub
Ad

Viewers also liked (12)

PDF
Starting with Git & GitHub
PPTX
Introduction to git and github
PDF
Intro to Git and GitHub
PDF
Introduction to GitHub
PPTX
Github basics
PPTX
Basic Git Intro
PPTX
Introduction to github slideshare
PDF
Git and Github
PPT
Git 101 - Crash Course in Version Control using Git
PPTX
Introduction to Git/Github - A beginner's guide
PDF
Gitlab Training with GIT and SourceTree
PDF
Git 101: Git and GitHub for Beginners
Starting with Git & GitHub
Introduction to git and github
Intro to Git and GitHub
Introduction to GitHub
Github basics
Basic Git Intro
Introduction to github slideshare
Git and Github
Git 101 - Crash Course in Version Control using Git
Introduction to Git/Github - A beginner's guide
Gitlab Training with GIT and SourceTree
Git 101: Git and GitHub for Beginners
Ad

Similar to Gittalk (20)

PDF
Introducción a git y GitHub
PDF
Loading...git
PDF
Introduction to Git for Artists
PDF
Git_real_slides
PDF
Wokshop de Git
PDF
Pro git - grasping it conceptually
PDF
Git and github 101
PDF
GIT_In_90_Minutes
PDF
Git Concepts, Commands and Connectivity
KEY
Working with Git
PDF
Git Started With Git
PDF
Git the Docs: A fun, hands-on introduction to version control
PPTX
Intro to Git DevOps Tally Presentation 101615
PDF
Introduction to git
PPTX
Hacktoberfest intro to Git and GitHub
PDF
Becoming a Git Master
PDF
Git cheat sheet with diagram-5.pdf
PDF
Collaborative development with Git | Workshop
PDF
Git Tricks — git utilities that make life git easier
PPTX
Working with Git
Introducción a git y GitHub
Loading...git
Introduction to Git for Artists
Git_real_slides
Wokshop de Git
Pro git - grasping it conceptually
Git and github 101
GIT_In_90_Minutes
Git Concepts, Commands and Connectivity
Working with Git
Git Started With Git
Git the Docs: A fun, hands-on introduction to version control
Intro to Git DevOps Tally Presentation 101615
Introduction to git
Hacktoberfest intro to Git and GitHub
Becoming a Git Master
Git cheat sheet with diagram-5.pdf
Collaborative development with Git | Workshop
Git Tricks — git utilities that make life git easier
Working with Git

Gittalk

Editor's Notes