Intro to Git for the Perl Hacker

Intro to Git for the Perl Hacker

This introduction to git is geared for a Perl hacker who is either a CPAN author without prior git experience or someone who is looking to contribute to a GitHub based CPAN project.

7330b65ea54e1b90a987a552e5c5cf32?s=128

Mark Allen

July 18, 2012
Tweet

Transcript

  1. Intro to Git! for Perl Hackers! ! ! Mark Allen!

    mrallen1@yahoo.com! @bytemeorg! http://byte-me.org! https://github.com/mrallen1! https://metacpan.org/author/MALLEN!
  2. Distributed ! Version ! Control! System!

  3. Fast! !

  4. Tons of features! !

  5. Uses lots of Perl internally! !

  6. Perl itself and many CPAN authors use it.! !

  7. Worst. Interface. Evar.!

  8. 1.  Terms and lingo! 2.  Basic workflow! 3.  Topic branches!

    4.  Starting and/or contributing to github projects.! 5.  Cool Perl stuff!
  9. Terms / Lingo http://marklodato.github.com/visual-git-guide/index-en.html!

  10. Terms / Lingo http://marklodato.github.com/visual-git-guide/index-en.html!

  11. Basics subversion! ! $ svn co \! https://example.com! $ vim

    myfile.pl! $ svn status! $ svn diff! $ svn ci -m'My commit'! git! ! $ git clone \! https://example.com! $ vim myfile.pl! $ git status! $ git add -- myfile.pl! $ git diff! $ git commit \! -m'My commit'! $ git push!
  12. Basics ! $ git clone https://example.com! $ vim myfile.pl! $

    git diff! $ git add myfile.pl ! $ git status! $ git commit -m'My commit'! $ git push origin master! origin   Where   What  
  13. I want to...! !create a new local repository! $ mkdir

    myproject! $ cd myproject! $ git init! Basics
  14. I want to...! ! ! !copy a remote repository! !

    $ git clone https://example.com! $ git clone git@example.com:project.git! Basics
  15. I want to...! ! ! !stage a file for a

    commit! ! $ git add -- myfile.pl! Basics
  16. I want to...! create a commit! ! $ git commit!

    Basics
  17. I want to...! add to the last commit! ! $

    git commit --amend! Basics
  18. I want to...! ! ! diff against a commit! !

    $ git diff! $ git diff HEAD^! $ git diff HEAD~4! $ git diff 1bc38 -- myfile.pl! Basics
  19. I want to...! ! ! ! see commit history! !

    $ git log! Basics
  20. I want to...! ! ! !update a local repository! !

    $ git pull! Basics
  21. I want to...! give a commit a memorable reference! !

    $ git tag mytag 1bec3! $ git push --tags! $ git diff mytag -- a.pl! Basics
  22. I want to...! add a remote storage location! ! $

    git remote add origin https://example.com! ! -also-! ! $ git remote rm origin! Basics
  23. I want to...! push my local work to a remote

    location! ! $ git push! $ git push -u origin foo! Basics
  24. I want to...! temporarily save my work
 and work on

    something else! $ git stash! # ...! $ git stash pop! Basics
  25. Git commands ! •  are (mostly) scripts! •  bash, perl,

    python! •  you can extend!
  26. Topic branches! ! •  What are they?! •  Why are

    they useful?! •  How do you use them?! Topic branches
  27. $ git branch rt14322! $ git checkout rt14322! -or-! $

    git checkout -b rt14322! ...! Topic branches
  28. $ git checkout master! $ git merge rt14322! Topic branches

  29. GitHub

  30. GitHub

  31. GitHub https://github.com/signup/free!

  32. GitHub

  33. GitHub

  34. GitHub

  35. GitHub

  36. GitHub

  37. GitHub

  38. GitHub

  39. GitHub

  40. GitHub

  41. GitHub

  42. GitHub

  43. GitHub

  44. GitHub

  45. GitHub

  46. GitHub

  47. GitHub

  48. GitHub

  49. GitHub

  50. GitHub

  51. GitHub

  52. GitHub

  53. GitHub

  54. GitHub

  55. GitHub

  56. GitHub

  57. GitHub

  58. GitHub Congratulations, your pull request was submitted!! ! Things to

    do now:! • Relax! • Have a beer! • Enjoy the accolades of a grateful Perl community!
  59. GitHub Use META.json to list code repo location. ! This

    example is for Module::Build!
  60. GitHub

  61. Augh! My CPAN module(s) are in CVS or SVN!! • 

    I'm sorry for your pain.! •  Github has tools and guides to help you migrate!
  62. Cool Perl Stuff! •  git-status-tackle! •  Git::Wrapper! •  App::GitHub! • 

    Pithub (GitHub API module)! ! Perl
  63. Git::CPAN::Patch! ! $ mkdir Foo-Bar! $ git cpan-init Foo::Bar! $

    git checkout -b quux! # ... hack hack ...! $ git commit -am "Add quux"! $ git cpan-sendpatch --compose! Perl
  64. Resources:! •  https://speakerdeck.com/u/mrallen1/p/intro-to-git! •  https://github.com/mrallen1/Acme-Github-Test (fork, send pull requests, experiment,

    etc)! •  http://git-scm.com (binaries, docs, tutorials)! •  http://marklodato.github.com/visual-git-guide/ index-en.html! ! https://tinyurl.com/git4perl!
  65. Thank you!! Questions?! https://tinyurl.com/git4perl!