SlideShare une entreprise Scribd logo
1  sur  30
Practical Git
Fun things we do with git
About Me/
Matt Weghorst, @mattweg
   COO by day, Dev by night
ESN Interactive - Hollywood, CA
   Lead Generation Marketing
   Small teams develop on a PHP5/CakePHP platform
   6 main applications, run 20+ sites, full API, deliver via clients’
   APIs
Distributed Revision Control

   CVS, SVN, and Git are the most
   popular (many others too)
   Common Concepts
      Repositories - Local and
      Remote
      Branching/Merging/
      Tagging
Why git?
Great external collaboration sites
   GitHub.com, TheChaw.com, etc
Really easy remote setup
No .svn directories
Great features, good documentation (http://git-scm.com/)
STABLE!
Installing git
OSX
       git-osx-installer - http://code.google.com/p/git-osx-
       installer/
       mac ports - http://macports.org/ (search for git-core)
       make, make install - http://git-scm.com/download
PC
       http://www.cygwin.com/ (Linux emulator)
       http://code.google.com/p/msysgit/
*nix
       http://git-scm.com/download
Git it (the basics)
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
`git clone [remote address]`- creates a local repo from an existing remote repo
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
`git clone [remote address]`- creates a local repo from an existing remote repo
`git status` - get used to typing this one (current status of the repo)
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
`git clone [remote address]`- creates a local repo from an existing remote repo
`git status` - get used to typing this one (current status of the repo)
`git diff [path/to/file.ext]` - shows un-committed changes to the selected file
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
`git clone [remote address]`- creates a local repo from an existing remote repo
`git status` - get used to typing this one (current status of the repo)
`git diff [path/to/file.ext]` - shows un-committed changes to the selected file
`git add [path/to/file.ext]` - adds the file to be included in the next commit
Git it (the basics)
Official git tutorial - http://git-scm.com/documentation
`git init`- start a clean repo and creates the .git directory in the project
`git clone [remote address]`- creates a local repo from an existing remote repo
`git status` - get used to typing this one (current status of the repo)
`git diff [path/to/file.ext]` - shows un-committed changes to the selected file
`git add [path/to/file.ext]` - adds the file to be included in the next commit
`git commit -m “[non-lame commit message]”` - creates the commit with the
included message
Going remote share some code already
Going remote share some code already
Easy option - http://GitHub.com
     public = free, private = cheap
     just configure your .ssh key and you can start cloning or creating projects
Going remote share some code already
Easy option - http://GitHub.com
     public = free, private = cheap
     just configure your .ssh key and you can start cloning or creating projects
Custom options (still much easier than svn remote)
     `ssh [remote.server.com]`- log in to your server (.ssh key is best)
     `mkdir [path/for/remote.git]`- wherever you want to store it
     `cd [path/for/remote.git]`
     `git --bare init` - empty repo is ready to be cloned
     `git clone [ssh://remote.server.com/path/for/remote.git]` - add files from local and push
Going rouge (branching)
Going rouge (branching)
Branch - variations of the code base inside a single repository
Going rouge (branching)
Branch - variations of the code base inside a single repository
    `git checkout master` - default branch
Going rouge (branching)
Branch - variations of the code base inside a single repository
    `git checkout master` - default branch
    `git branch [newbranch]` - create a new branch based on the
    HEAD revision of the current branch
Going rouge (branching)
Branch - variations of the code base inside a single repository
    `git checkout master` - default branch
    `git branch [newbranch]` - create a new branch based on the
    HEAD revision of the current branch
    `git checkout [newbranch]` - keep things separate until you
    decide to...
Going rouge (branching)
Branch - variations of the code base inside a single repository
    `git checkout master` - default branch
    `git branch [newbranch]` - create a new branch based on the
    HEAD revision of the current branch
    `git checkout [newbranch]` - keep things separate until you
    decide to...
    `git merge [frombranch]` - takes all of the changes from the
    specified branch and merges into the current branch
Who broke that?   viewing history
Who broke that?                        viewing history


`git log` - shows commit history
   very powerful, read the docs and you’ll figure out how to find what
   you are looking for
Who broke that?                        viewing history


`git log` - shows commit history
   very powerful, read the docs and you’ll figure out how to find what
   you are looking for
`git show [commit]`- see what changed in the specific commit
Who broke that?                        viewing history


`git log` - shows commit history
   very powerful, read the docs and you’ll figure out how to find what
   you are looking for
`git show [commit]`- see what changed in the specific commit
`git blame [path/to/file.ext]` - see who and which commit is
responsible for each line of a file
Who broke that?                          viewing history


`git log` - shows commit history
    very powerful, read the docs and you’ll figure out how to find what
    you are looking for
`git show [commit]`- see what changed in the specific commit
`git blame [path/to/file.ext]` - see who and which commit is
responsible for each line of a file
`git bisect` - totally awesome - helps you figure out exactly which
commit created a bug
How we use git                   and we’re pretty awesome


Everybody uses it - even designers
Staging server holds all of our remote repositories
post-commit hook automatically pushes commits to the
staging server for testing
after testing, the `golive` shell script lets you review
changes since last publish and sends to our production
servers
Check me out                     some awesome commands


`git log live..master --no-merges
--pretty=format:'%h by %an, %ar,
message: %s'`
`git show [rev#] --stat`
`git diff live..master --stat`
`git cherry-pick -x [rev#]`
Practical Git

Contenu connexe

En vedette

En vedette (20)

Device Drivers in Linux
Device Drivers in LinuxDevice Drivers in Linux
Device Drivers in Linux
 
Breaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success StoryBreaking into Open Source and Linux: A USB 3.0 Success Story
Breaking into Open Source and Linux: A USB 3.0 Success Story
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Raspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry PiRaspberry Pi - Lecture 6 Working on Raspberry Pi
Raspberry Pi - Lecture 6 Working on Raspberry Pi
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
Workflow para volar con el CSS
Workflow para volar con el CSSWorkflow para volar con el CSS
Workflow para volar con el CSS
 
Mejora tus US con UX y modelos de satisfacción
Mejora tus US con UX y modelos de satisfacciónMejora tus US con UX y modelos de satisfacción
Mejora tus US con UX y modelos de satisfacción
 
Introducción a Google Dart + HTML5
Introducción a Google Dart + HTML5Introducción a Google Dart + HTML5
Introducción a Google Dart + HTML5
 
REST, jQuery y otros Frameworks JS
REST, jQuery y otros Frameworks JSREST, jQuery y otros Frameworks JS
REST, jQuery y otros Frameworks JS
 
Ejemplo de corrección de errores de accesibilidad WCAG 2.0 en una página web
Ejemplo de corrección de errores de accesibilidad WCAG 2.0 en una página webEjemplo de corrección de errores de accesibilidad WCAG 2.0 en una página web
Ejemplo de corrección de errores de accesibilidad WCAG 2.0 en una página web
 
Desarrollo de Mobile Web Apps
Desarrollo de Mobile Web AppsDesarrollo de Mobile Web Apps
Desarrollo de Mobile Web Apps
 
Integración de WAI-ARIA en HTML5
Integración de WAI-ARIA en HTML5Integración de WAI-ARIA en HTML5
Integración de WAI-ARIA en HTML5
 
Accesibilidad, hojas estilo cascada, y tu
Accesibilidad, hojas estilo cascada, y tuAccesibilidad, hojas estilo cascada, y tu
Accesibilidad, hojas estilo cascada, y tu
 
Tools and Frameworks
Tools and FrameworksTools and Frameworks
Tools and Frameworks
 
Desarrollo de webapps 1
Desarrollo de webapps 1Desarrollo de webapps 1
Desarrollo de webapps 1
 
Uso de html5 + webcomponents
Uso de html5 + webcomponentsUso de html5 + webcomponents
Uso de html5 + webcomponents
 
Linux Kernel Introduction
Linux Kernel IntroductionLinux Kernel Introduction
Linux Kernel Introduction
 
Casper JS - Asegurando la calidad en front-end Drupal
Casper JS - Asegurando la calidad en front-end DrupalCasper JS - Asegurando la calidad en front-end Drupal
Casper JS - Asegurando la calidad en front-end Drupal
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Practical Git

  • 1. Practical Git Fun things we do with git
  • 2. About Me/ Matt Weghorst, @mattweg COO by day, Dev by night ESN Interactive - Hollywood, CA Lead Generation Marketing Small teams develop on a PHP5/CakePHP platform 6 main applications, run 20+ sites, full API, deliver via clients’ APIs
  • 3. Distributed Revision Control CVS, SVN, and Git are the most popular (many others too) Common Concepts Repositories - Local and Remote Branching/Merging/ Tagging
  • 4. Why git? Great external collaboration sites GitHub.com, TheChaw.com, etc Really easy remote setup No .svn directories Great features, good documentation (http://git-scm.com/) STABLE!
  • 5. Installing git OSX git-osx-installer - http://code.google.com/p/git-osx- installer/ mac ports - http://macports.org/ (search for git-core) make, make install - http://git-scm.com/download PC http://www.cygwin.com/ (Linux emulator) http://code.google.com/p/msysgit/ *nix http://git-scm.com/download
  • 6. Git it (the basics)
  • 7. Git it (the basics) Official git tutorial - http://git-scm.com/documentation
  • 8. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project
  • 9. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo
  • 10. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo)
  • 11. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file
  • 12. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file `git add [path/to/file.ext]` - adds the file to be included in the next commit
  • 13. Git it (the basics) Official git tutorial - http://git-scm.com/documentation `git init`- start a clean repo and creates the .git directory in the project `git clone [remote address]`- creates a local repo from an existing remote repo `git status` - get used to typing this one (current status of the repo) `git diff [path/to/file.ext]` - shows un-committed changes to the selected file `git add [path/to/file.ext]` - adds the file to be included in the next commit `git commit -m “[non-lame commit message]”` - creates the commit with the included message
  • 14. Going remote share some code already
  • 15. Going remote share some code already Easy option - http://GitHub.com public = free, private = cheap just configure your .ssh key and you can start cloning or creating projects
  • 16. Going remote share some code already Easy option - http://GitHub.com public = free, private = cheap just configure your .ssh key and you can start cloning or creating projects Custom options (still much easier than svn remote) `ssh [remote.server.com]`- log in to your server (.ssh key is best) `mkdir [path/for/remote.git]`- wherever you want to store it `cd [path/for/remote.git]` `git --bare init` - empty repo is ready to be cloned `git clone [ssh://remote.server.com/path/for/remote.git]` - add files from local and push
  • 18. Going rouge (branching) Branch - variations of the code base inside a single repository
  • 19. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch
  • 20. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch
  • 21. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch `git checkout [newbranch]` - keep things separate until you decide to...
  • 22. Going rouge (branching) Branch - variations of the code base inside a single repository `git checkout master` - default branch `git branch [newbranch]` - create a new branch based on the HEAD revision of the current branch `git checkout [newbranch]` - keep things separate until you decide to... `git merge [frombranch]` - takes all of the changes from the specified branch and merges into the current branch
  • 23. Who broke that? viewing history
  • 24. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for
  • 25. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit
  • 26. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit `git blame [path/to/file.ext]` - see who and which commit is responsible for each line of a file
  • 27. Who broke that? viewing history `git log` - shows commit history very powerful, read the docs and you’ll figure out how to find what you are looking for `git show [commit]`- see what changed in the specific commit `git blame [path/to/file.ext]` - see who and which commit is responsible for each line of a file `git bisect` - totally awesome - helps you figure out exactly which commit created a bug
  • 28. How we use git and we’re pretty awesome Everybody uses it - even designers Staging server holds all of our remote repositories post-commit hook automatically pushes commits to the staging server for testing after testing, the `golive` shell script lets you review changes since last publish and sends to our production servers
  • 29. Check me out some awesome commands `git log live..master --no-merges --pretty=format:'%h by %an, %ar, message: %s'` `git show [rev#] --stat` `git diff live..master --stat` `git cherry-pick -x [rev#]`

Notes de l'éditeur