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

Intro to Git for the Python Hacker

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for Jade Allen Jade Allen
September 14, 2012

Intro to Git for the Python Hacker

A gentle introduction to git for a python programmer

Avatar for Jade Allen

Jade Allen

September 14, 2012
Tweet

More Decks by Jade Allen

Other Decks in Technology

Transcript

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

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

    4.  Starting and/or contributing to github projects.! 5.  Cool Python stuff!
  3. Basics subversion! ! $ svn co \! https://example.com! $ vim

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

    git diff! $ git add myfile.py ! $ 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.py! 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.py! Basics
  10. I want to...! give a commit a memorable reference! !

    $ git tag mytag 1bec3! $ git push --tags! $ git diff mytag -- a.py! 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 tasty beverage! • Enjoy the accolades of a grateful Python community!
  17. Augh! My library is in CVS or SVN!! •  I'm

    sorry for your pain.! •  Github has tools and guides to help you migrate!
  18. Cool Python Stuff! •  dulwich, a pure python git implementation!

    •  GitPython, wraps git command line tools! •  Legit, a more humane git CLI (by Kenneth Reitz)! Python
  19. Cool Python Stuff! •  pygit2 - Python binding for libgit2

    (an alternative C implementation)! •  git-cola - a graphical git client written in Python! Python