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

Git it on (includes GitHub)

Git it on (includes GitHub)

This presentation was an intro to Git and usage of GitHub. Given at Syntra Mechelen 4th June 2013. It does not cover branching, just the basics of Git and a quickstart guide with guidelines.

Martin Bing

June 04, 2013
Tweet

Other Decks in Programming

Transcript

  1. GIT WHAT? Open Source Distributed Version Control System (DVCS) (VCS)

    aka Source Code Management (SCM) Tool to keep track of changes (in files) Command Line (BASH) Supported by UNIX-like systems (Linux, Mac OS X, Solaris) and Windows
  2. HISTORY GIT created in 2005 by Linus Torvalds Developed on

    a Linux (what else?) Made in 2 weeks Why pay if you can build it better (ref. BitKeeper) See the man in action: Linus Torvalds on Git
  3. PREDECESSORS (SCCS) Source Code Control System 1972, closed source (FIFO)

    (RCS) Revision Control System 1982, open source (LIFO) (CVS) Concurrent Versions System 1986-1990, open source (+users on 1 file) (SVN) Apache Subversion 2000, open source (+non-txt-files) (SCM) BitKeeper 2000, closed source, proprietary free 'community version' till april 2005 (used for linux kernel 2002-2005)
  4. WHY USE GIT? To check edits (code) review history log

    of changes view diff between versions retrieve old versions To share changes with collabs
  5. !!! GIT CAN NOT TRACK !!! Non-text files binary files

    (imgs etc..) Word Processing files Spreadsheets PDF's
  6. GIT WHO? People NOT afraid of command-line tools Programmers &

    developers mainly used languages: HTML CSS JavaScript ...
  7. SET UP GIT DOWNLOAD: INSTALL See guidelines or following slides

    to view the set up process (Windows) http://git-scm.com/downloads here
  8. GIT UP SET Create an account on: username : email:

    https://github.com/signup/free $ g i t c o n f i g - - g l o b a l u s e r . n a m e " Y o u r n a m e h e r e " # S e t s t h e d e f a u l t n a m e f o r g i t t o u s e w h e n y o u c o m m i t $ g i t c o n f i g - - g l o b a l u s e r . e m a i l " Y o u r e m a i l h e r e " # S e t s t h e d e f a u l t e m a i l f o r g i t t o u s e w h e n y o u c o m m i t
  9. GIT BASH # s o m e B A S

    H c o m m a n d s y o u w i l l u s e q u i t e o f t e n f r o m n o w o n : $ l s # s h o w c o n t e n t s o f d i r e c t o r y y o u a r e i n $ c d D o c u m e n t s $ m k d i r g i t _ m b $ c d g i t _ m b $ g i t i n i t # i n i t i a l i s e t h i s w o r k i n g d i r e c t o r y a s a n e w r e p o $ t o u c h R E A D M E . m d $ v i R E A D M E . m d # y o u c a n e d i t t h i s f i l e i n a n y t e x t b a s e d e d i t o r l i k e n o t e p a d
  10. GIT STATUS M a r t i n @ M

    B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r # # I n i t i a l C o m m i t # # U n t r a c k e d f i l e s : # ( u s e " g i t a d d < f i l e > . . . " t o i n c l u d e i n w h a t w i l l b e c o m m i t t e d ) # # R E A D M E . m d n o t h i n g a d d e d t o c o m m i t b u t u n t r a c k e d f i l e s p r e s e n t ( u s e " g i t a d d " t o t r a c k ) M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $
  11. GIT ADD M a r t i n @ M

    B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t a d d R E A D M E . m d M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r # # I n i t i a l C o m m i t # # C h a n g e s t o b e c o m m i t t e d : # ( u s e " g i t r m - - c a c h e d < f i l e > . . . " t o u n s t a g e ) # # n e w f i l e : R E A D M E . m d # M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $
  12. GIT COMMIT M a r t i n @ M

    B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t c o m m i t - m ' I n i t i a l i s e r e p o a n d c r e a t i o n o f r e a d m e f i l e ' [ m a s t e r ( r o o t - c o m m i t ) e 8 8 1 f a a ] i n i t i a l i s e r e p o a n d c r e a t i o n o f r e a d m e f i l e 1 f i l e c h a n g e d , 1 i n s e r t i o n ( + ) c r e a t e m o d e 1 0 0 6 4 4 R E A D M E . m d M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r n o t h i n g t o c o m m i t , w o r k i n g d i r e c t o r y c l e a n M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $
  13. GIT LOG M a r t i n @ M

    B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t l o g c o m m i t e 8 8 1 f a a 0 5 1 b 1 f b 5 e 5 1 0 7 4 e 0 5 e 8 8 a 7 4 4 3 4 9 c b 9 7 a 6 A u t h o r : M B i n g < e m a i l @ s o m e d o m a i n . c o m > D a t e : M o n J u n 3 2 2 : 3 8 : 3 2 2 0 1 3 + 0 2 0 0 I n i t i a l i s e r e p o a n d c r e a t i o n o f r e a d m e f i l e M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $
  14. WHAT IS GITHUB? Web Based Hosting Service for software development

    Uses Git revision control system Free for open source repo's Paid plans available for private repo's easy to use GUI's available Makes the use of Git easier for most people https://help.github.com/
  15. GITHUB CLONE This is your own folder, not the original

    repo!! (look for your username in the git uri)
  16. GIT CLONE M a r t i n @ M

    B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ g i t c l o n e h t t p s : / / g i t h u b . c o m / y o u r u s e r n a m e / G I T - p r e s e n t a t i o n . g i t C l o n i n g i n t o ' G I T - p r e s e n t a t i o n ' . . . r e m o t e : C o u n t i n g o b j e c t s : 6 , d o n e . r e m o t e : C o m p r e s s i n g o b j e c t s : 1 0 0 % ( 4 / 4 ) , d o n e . r e m o t e : T o t a l 6 ( d e l t a 1 ) , r e u s e d 0 ( d e l t a 0 ) U n p a c k i n g o b j e c t s : 1 0 0 % ( 6 / 6 ) , d o n e . M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $ l s G I T - p r e s e n t a t i o n $ c d G I T - p r e s e n t a t i o n / $ l s R E A D M E . m d M a r t i n @ M B - P C ~ / D o c u m e n t s / g i t _ m b ( m a s t e r ) $
  17. GIT ADD NEW FILE M a r t i n

    @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ t o u c h y o u r n a m e . h t m l M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r # U n t r a c k e d f i l e s : # ( u s e " g i t a d d < f i l e > . . . " t o i n c l u d e i n w h a t w i l l b e c o m m i t t e d ) # # y o u r n a m e . h t m l n o t h i n g a d d e d t o c o m m i t b u t u n t r a c k e d f i l e s p r e s e n t ( u s e g i t " g i t a d d " t o t r a c k ) M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $
  18. GIT ADD M a r t i n @ M

    B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t a d d y o u r n a m e . h t m l M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r # C h a n g e s t o b e c o m m i t t e d : # ( u s e " g i t r e s e t H E A D < f i l e > . . . " t o u n s t a g e ) # # n e w f i l e : y o u r n a m e . h t m l # M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $
  19. GIT COMMIT M a r t i n @ M

    B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t c o m m i t - m ' a d d i n g a n h t m l f i l e w i t h m y n a m e ' [ m a s t e r 3 2 8 e 0 c b ] a d d i n g a n h t m l f i l e w i t h m y n a m e 1 f i l e c h a n g e d , 0 i n s e r t i o n s ( + ) , 0 d e l e t i o n s ( - ) c r e a t e m o d e 1 0 0 6 4 4 y o u r n a m e . h t m l M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r # Y o u r b r a n c h i s a h e a d o f ' o r i g i n / m a s t e r ' b y 1 c o m m i t . # ( u s e " g i t p u s h " t o p u b l i s h y o u r l o c a l c o m m i t s ) # n o t h i n g t o c o m m i t , w o r k i n g d i r e c t o r y c l e a n M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $
  20. GIT PUSH M a r t i n @ M

    B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t p u s h o r i g i n m a s t e r C o u n t i n g o b j e c t s : 4 d o n e . D e l t a c o m p r e s s i o n u s i n g u p t o 2 t h r e a d s . C o m p r e s s i n g o b j e c t s : 1 0 0 % ( 2 / 2 ) , d o n e . W r i t i n g o b j e c t s : 1 0 0 % ( 3 / 3 ) , 3 0 2 b y t e s , d o n e . T o t a l 3 ( d e l t a 0 ) , r e u s e d 0 ( d e l t a 0 ) T o h t t p s : / / g i t h u b . c o m / y o u r n a m e / G I T - p r e s e n t a t i o n . g i t a d 7 6 4 d c . . 3 2 8 e 0 c b m a s t e r - > m a s t e r M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $ g i t s t a t u s # O n b r a n c h m a s t e r n o t h i n g t o c o m m i t , w o r k i n g d i r e c t o r y c l e a n M a r t i n @ M B - P C ~ / D o c u m e n t s / G I T - p r e s e n t a t i o n ( m a s t e r ) $
  21. RESOURCES The Pro Git book by Scott Chacun: Heroku Cheat

    Sheet : YouTube: (Patrick Hogan) http://git-scm.com/book Cheat Sheet PDF file link Introduction to Git with Scott Chacun Power Your Workflow with Git