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. 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. 3.
  3. 8.

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

    4.  Starting and/or contributing to github projects.! 5.  Cool Perl stuff!
  4. 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!
  5. 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  
  6. 13.

    I want to...! !create a new local repository! $ mkdir

    myproject! $ cd myproject! $ git init! Basics
  7. 14.

    I want to...! ! ! !copy a remote repository! !

    $ git clone https://example.com! $ git clone git@example.com:project.git! Basics
  8. 15.

    I want to...! ! ! !stage a file for a

    commit! ! $ git add -- myfile.pl! Basics
  9. 17.

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

    git commit --amend! Basics
  10. 18.

    I want to...! ! ! diff against a commit! !

    $ git diff! $ git diff HEAD^! $ git diff HEAD~4! $ git diff 1bc38 -- myfile.pl! Basics
  11. 21.

    I want to...! give a commit a memorable reference! !

    $ git tag mytag 1bec3! $ git push --tags! $ git diff mytag -- a.pl! Basics
  12. 22.

    I want to...! add a remote storage location! ! $

    git remote add origin https://example.com! ! -also-! ! $ git remote rm origin! Basics
  13. 23.

    I want to...! push my local work to a remote

    location! ! $ git push! $ git push -u origin foo! Basics
  14. 24.

    I want to...! temporarily save my work
 and work on

    something else! $ git stash! # ...! $ git stash pop! Basics
  15. 26.

    Topic branches! ! •  What are they?! •  Why are

    they useful?! •  How do you use them?! Topic branches
  16. 27.

    $ git branch rt14322! $ git checkout rt14322! -or-! $

    git checkout -b rt14322! ...! Topic branches
  17. 29.
  18. 30.
  19. 32.
  20. 33.
  21. 34.
  22. 35.
  23. 36.
  24. 37.
  25. 38.
  26. 39.
  27. 40.
  28. 41.
  29. 42.
  30. 43.
  31. 44.
  32. 45.
  33. 46.
  34. 47.
  35. 48.
  36. 49.
  37. 50.
  38. 51.
  39. 52.
  40. 53.
  41. 54.
  42. 55.
  43. 56.
  44. 57.
  45. 58.

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

    do now:! • Relax! • Have a beer! • Enjoy the accolades of a grateful Perl community!
  46. 60.
  47. 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!
  48. 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
  49. 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!