Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

Jade Allen

July 18, 2012
Tweet

More Decks by Jade Allen

Other Decks in Programming

Transcript

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

    [email protected]! @bytemeorg! http://byte-me.org! https://github.com/mrallen1! https://metacpan.org/author/MALLEN!
  2. 1.  Terms and lingo! 2.  Basic workflow! 3.  Topic branches!

    4.  Starting and/or contributing to github projects.! 5.  Cool Perl stuff!
  3. 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!
  4. 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  
  5. I want to...! !create a new local repository! $ mkdir

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

    $ git clone https://example.com! $ git clone [email protected]:project.git! Basics
  7. I want to...! ! ! !stage a file for a

    commit! ! $ git add -- myfile.pl! Basics
  8. I want to...! add to the last commit! ! $

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

    $ git diff! $ git diff HEAD^! $ git diff HEAD~4! $ git diff 1bc38 -- myfile.pl! Basics
  10. I want to...! give a commit a memorable reference! !

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

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

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

    something else! $ git stash! # ...! $ git stash pop! Basics
  14. Topic branches! ! •  What are they?! •  Why are

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

    git checkout -b rt14322! ...! Topic branches
  16. GitHub Congratulations, your pull request was submitted!! ! Things to

    do now:! • Relax! • Have a beer! • Enjoy the accolades of a grateful Perl community!
  17. 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!
  18. 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
  19. 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!