Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Git, DrupalCamp LA 2015

407 views

Published on

Matthew Wrather gives an Introduction to the Git version control system at DrupalCamp LA 2015, presented by Los Angels Drupal.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Introduction to Git, DrupalCamp LA 2015

  1. 1. INTRODUCTIONTO GIT Drupal Camp LA 2015 Matthew Wrather Wrather Creative
  2. 2. RACONTEUR BONVIVANT MAN OF MYSTERY matt@wrathercreative.com @mwrather
  3. 3. SOURCES • A great talk by @merlyn himself, Randal Schwartz CC-BY-SA • OnVimeo at https://vimeo.com/35778382 • Slides at http://slidesha.re/z7nQrG • Pro Git by Scott Chacon CC-BY-NC-SA • Read for free at http://git-scm.com/book • And many more at http://lmgtfy.com/?q=git+tutorial
  4. 4. AGENDA 1.Why UseVersion Control 2. Git basic concepts 3. Demo Time for questions after each section.
  5. 5. DOESN’T USEVERSION CONTROL slworking on Flickr CC-BY-NC-SA
  6. 6. WHAT IS GIT FOR? Git is for… • Tracks a tree of related files • Distributed • High Performance • Easy & Fast Branch/Merge • Good Data Integrity • Collaborative
 Git is not for… • Tracking unrelated files • Tracking File Metadata • Binary Files
  7. 7. DEMO
  8. 8. WRAPYOUR MIND AROUND • Distributed:Your repository is complete unto itself. • Anyone can commit!* *To their own repo. • (Once you start fetching and pushing work,
 permissions come into play.) • There can still be a central, blessed repo. • Universal Public Identifiers: SHA1 hashes
  9. 9. OBJECTS IN GIT • Blobs (actual data) • Trees (directories of blobs or of other trees) • A commit, which is: • A tree • Zero or more parent commits • Metadata (commit message, name email, timestamp)
  10. 10. graphic from Pro Git by Scott Chacon CC-BY-NC-SA
  11. 11. QUESTIONS?
  12. 12. WE NEEDTOTALK ABOUT COMMITMENT Do this Work Stage Commit
 here Filesystem Staging Area Repository
 (aka here) WorkingTree Index HEAD
 by writing code git add git commit Rinse and Repeat
  13. 13. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES
  14. 14. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES $ git commit
  15. 15. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES $ git branch testing
  16. 16. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES
  17. 17. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES $ git checkout testing
  18. 18. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES $ subl awesome.module $ git add awesome.module $ git commit -m ‘changed awesome module’
  19. 19. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES $ git checkout master
  20. 20. graphic from Pro Git by Scott Chacon CC-BY-NC-SA BRANCHES
  21. 21. graphic from Pro Git by Scott Chacon CC-BY-NC-SA MERGING
  22. 22. graphic from Pro Git by Scott Chacon CC-BY-NC-SA MERGING $ git checkout -b iss53 # shortcut for: $ # git branch iss53 $ # git checkout iss53
  23. 23. graphic from Pro Git by Scott Chacon CC-BY-NC-SA MERGING
  24. 24. graphic from Pro Git by Scott Chacon CC-BY-NC-SA MERGING
  25. 25. FAST FORWARD MERGE $ git checkout master $ git merge hotfix
  26. 26. graphic from Pro Git by Scott Chacon CC-BY-NC-SA FAST FORWARD MERGE
  27. 27. graphic from Pro Git by Scott Chacon CC-BY-NC-SA FAST FORWARD MERGE
  28. 28. graphic from Pro Git by Scott Chacon CC-BY-NC-SA FAST FORWARD MERGE $ git branch -d hotfix
  29. 29. graphic from Pro Git by Scott Chacon CC-BY-NC-SA RECURSIVE MERGE
  30. 30. graphic from Pro Git by Scott Chacon CC-BY-NC-SA RECURSIVE MERGE $ git checkout master $ git merge iss53
  31. 31. DEMO
  32. 32. graphic from Pro Git by Scott Chacon CC-BY-NC-SA REBASING
  33. 33. graphic from Pro Git by Scott Chacon CC-BY-NC-SA REBASING
  34. 34. graphic from Pro Git by Scott Chacon CC-BY-NC-SA REBASING
  35. 35. graphic from Pro Git by Scott Chacon CC-BY-NC-SA REBASING $ git checkout experiment $ git rebase master
  36. 36. Thou shalt not rebase commits that you have pushed to a remote repository.
  37. 37. REMOTE REPOSITORIES • All these things that we’ve done so far happen in the privacy of our own computer and don’t affect anything else. • As a beginner, you are going to be using other people’s repositories more than you are going to create your own git clone <remoteUrl> • <remoteURL> can be HTTP, SSH, or git:// depending on your permissions
  38. 38. REMOTE REPOSITORIES • When you copy a repo using the git clone command,
 you’ll automatically have a remote called origin • It’s possible to have many, many remotes. It can be hard to keep track of.You probably don’t need to worry about it.
  39. 39. REMOTE REPOSITORIES • When you’ve done working, you can “push” your work up to a remote repository git push <remote-nickname> <branch> git push origin master • But if someone else has done work and pushed it to the remote repo, git won’t let you overwrite.
  40. 40. REMOTE REPOSITORIES • To find out what’s on the server, you can “fetch” from a remote repository git fetch <remote-nickname> git fetch origin • Remote branches will be tracked locally, prefixed with the remote nickname.The master branch on origin becomes origin/master locally.
  41. 41. REMOTE REPOSITORIES $ git push origin master [git error message] $ git fetch origin $ git merge origin/master $ git push master [HUGE SUCCESS!]
  42. 42. DEMO
  43. 43. QUESTIONS?
  44. 44. THANKYOU! Matthew Wrather • @mwrather matt@wrathercreative.com • (510) WRA-THER

×