SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (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
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

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#]`

Hinweis der Redaktion