SlideShare una empresa de Scribd logo
1 de 76
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

Más contenido relacionado

La actualidad más candente

Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Gitgittower
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Codemotion
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Git Acquainted
Git AcquaintedGit Acquainted
Git Acquaintedtylerhunt
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advancedYodalee
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshellalignan
 
Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails UndergroundAriejan de Vroom
 
Git for beginner
Git for beginnerGit for beginner
Git for beginnerTrung Huynh
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitRick Umali
 

La actualidad más candente (20)

Git real slides
Git real slidesGit real slides
Git real slides
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
Git
GitGit
Git
 
Undoing Things in Git
Undoing Things in GitUndoing Things in Git
Undoing Things in Git
 
Git internals
Git internalsGit internals
Git internals
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
GIT - GOOD PRACTICES
GIT - GOOD PRACTICESGIT - GOOD PRACTICES
GIT - GOOD PRACTICES
 
Git Acquainted
Git AcquaintedGit Acquainted
Git Acquainted
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
 
Git for beginner
Git for beginnerGit for beginner
Git for beginner
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010Matt Gauger - Git & Github web414 December 2010
Matt Gauger - Git & Github web414 December 2010
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 

Destacado

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and githubAderemi Dadepo
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHubNishan Bose
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeTeerapat Khunpech
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners HubSpot
 

Destacado (12)

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to git and github
Introduction to git and githubIntroduction to git and github
Introduction to git and github
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHub
 
Github basics
Github basicsGithub basics
Github basics
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 

Similar a Gittalk

Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHubLucas Videla
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for ArtistsDavid Newbury
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptuallyseungzzang Kim
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityRaja Soundaramourty
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With GitNick Quaranto
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | WorkshopAnuchit Chalothorn
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 

Similar a Gittalk (20)

Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git_real_slides
Git_real_slidesGit_real_slides
Git_real_slides
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Git cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdfGit cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdf
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Working with Git
Working with GitWorking with Git
Working with Git
 

Gittalk

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n