SlideShare uma empresa Scribd logo
1 de 12
Baixar para ler offline
Deploy easily!
with
Igor Santos
Web developer
● From Rio de Janeiro, Brazil
● PHP Developer for ~6 years
● Ruby and JS Developer for fun
● Playing around with git for ~2 years
slideshare.net/igorsantos07
0. Introduction
● Knows what Git is?
● Have ever used Git in the command line?
● Have ever deployed code?
○ How? SCP? WGet?
● Anyone developing in the production server?
1. Git Basics
● Commit: Saves changes with a description
● Pull: Get commits from a server
● Push: Send commits to a server
● Remotes
○ A remote machine that has a copy of the repository
and accepts your commits
○ In a common centralized organization you usually
have one, but it's possible to have many
○ Example: main repo is BitBucket or Google Code,
mirrored to GitHub
2. Configure your server
igor@local$ ssh santos@bluenose.cs.dal.ca
password: **********
santos@bluenose$ mkdir repos
santos@bluenose$ cd repos
santos@bluenose$ pwd
/users/cs/santos/repos
santos@bluenose$ git clone «repo» myRep --bare
This creates a clone of that repository that works just as
another repository: with all administrative data, but not
useable for development, as the code is not really checked
in - just the Git meta-data.
Take note
igor@local$ cd dev/myCode
igor@local$ git remote add prod
ssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRep
igor@local$ "Hi there!" > README.mkd
igor@local$ git commit "+ Adding readme"
igor@local$ git push prod
2. Configure your server
Name given to the remote server
Complete repository URL
No line break!
igor@local$ git commit "+ Adding readme"
igor@local$ git push prod
Q: OK, so... where's my README file?
A: In the repository!
Q: I can't see it. «not really a question»
2. Configure your server
3. Git Hooks
● 2 types: client and server hooks
● Client:
○ pre/post-commit
○ [prepare-]commit-msg
○ post-checkout, post-merge
● Server:
○ pre/post-receive Once per push
○ update Once per pushed branch
http://git-scm.com/book/en/Customizing-Git-Git-Hooks
3. Git Hooks
Simple copy
$ cat hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/mysite git checkout -f
Opposite of git clone --bare: copies the entire repository
code, without git data. By default does that with the master
branch, but you can use other options here as well.
GIT_WORK_TREE tells git where it would copy stuff.
3. Git Hooks
Complete deployment script
https://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
4. Advanced ideas
GitHub and other Git online repositories
have options to do HTTP requests with code
information after pushes, similar to post-
receive hooks. This data can be used to
trigger a deployment script in the server.
There's also an online service called
DeployHQ, where you can configure any
repository (SVN/Git/Hg) and many deploy
methods (FTP/SFTP/S3/Rackspace).
It deploys new code using the chosen method.
4. Adv.
ideas
deployhq.com

Mais conteúdo relacionado

Mais procurados

A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model abodeltae
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CIOlinData
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-trainingEric Guo
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CIColCh
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabShinu Suresh
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware CompanyEvan Lin
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIIvan Nemytchenko
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaBo-Yi Wu
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesJenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesChristian Münch
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for BeginnersMortezaTaghaddomi
 

Mais procurados (20)

A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Juc boston2014.pptx
Juc boston2014.pptxJuc boston2014.pptx
Juc boston2014.pptx
 
Git flow
Git flowGit flow
Git flow
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-training
 
Git best practices 2016
Git best practices 2016Git best practices 2016
Git best practices 2016
 
Git
GitGit
Git
 
Using GitLab CI
Using GitLab CIUsing GitLab CI
Using GitLab CI
 
Git workflows
Git workflowsGit workflows
Git workflows
 
GitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLabGitFlow, SourceTree and GitLab
GitFlow, SourceTree and GitLab
 
Git
GitGit
Git
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware Company
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CI
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-PipelinesJenkins to Gitlab - Intelligent Build-Pipelines
Jenkins to Gitlab - Intelligent Build-Pipelines
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for Beginners
 

Destaque

Introduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby HuntIntroduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby Huntpebble {code}
 
Accomplishments-Certifications
Accomplishments-CertificationsAccomplishments-Certifications
Accomplishments-CertificationsMelissa Schaefer
 
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Dusan Stojnic
 
More Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalMore Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalJohn Fall
 
Ch 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCh 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCraig Campbell
 
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaLandskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaMikaela Jussila
 
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesChoose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesCorstton Coaches
 
PivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationPivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationMike Santeramo
 
Huuhedin suvilahgui 1
Huuhedin suvilahgui 1Huuhedin suvilahgui 1
Huuhedin suvilahgui 1oyunubuns
 
Safety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSafety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSebastiano Trapani
 
Comparatividad Entre Piscis Y Acuarius
Comparatividad Entre  Piscis Y  AcuariusComparatividad Entre  Piscis Y  Acuarius
Comparatividad Entre Piscis Y Acuariusguest6942b5
 
Rezultate Eco-Scoala
Rezultate Eco-ScoalaRezultate Eco-Scoala
Rezultate Eco-ScoalaProfesorgeo
 

Destaque (17)

Introduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby HuntIntroduction to Kaizen by Toby Hunt
Introduction to Kaizen by Toby Hunt
 
Accomplishments-Certifications
Accomplishments-CertificationsAccomplishments-Certifications
Accomplishments-Certifications
 
Boquita deluna
Boquita delunaBoquita deluna
Boquita deluna
 
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
Potocnik et al - Efekti i optimizacija rada višefunkcionalne mašine u slučaju...
 
The euro
The euroThe euro
The euro
 
More Leadership Lessons Workshop Global
More Leadership Lessons Workshop GlobalMore Leadership Lessons Workshop Global
More Leadership Lessons Workshop Global
 
HEAT TRANSFER
HEAT TRANSFERHEAT TRANSFER
HEAT TRANSFER
 
Ch 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and MetalCh 1- Water and Soil, Stone and Metal
Ch 1- Water and Soil, Stone and Metal
 
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus PohjanmaallaLandskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
Landskapsreformen i Österbotten - Maakuntauudistus Pohjanmaalla
 
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire ServicesChoose Coach Hire Adelaide or Adelaide Coach Hire Services
Choose Coach Hire Adelaide or Adelaide Coach Hire Services
 
Patientencommunicatie
PatientencommunicatiePatientencommunicatie
Patientencommunicatie
 
PivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_OccupationPivotReseller_Sales_Profit_by_Country_and_Occupation
PivotReseller_Sales_Profit_by_Country_and_Occupation
 
Huuhedin suvilahgui 1
Huuhedin suvilahgui 1Huuhedin suvilahgui 1
Huuhedin suvilahgui 1
 
Unit 2
Unit 2Unit 2
Unit 2
 
Safety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento viraleSafety Leadership Event 2016 - Leader del miglioramento virale
Safety Leadership Event 2016 - Leader del miglioramento virale
 
Comparatividad Entre Piscis Y Acuarius
Comparatividad Entre  Piscis Y  AcuariusComparatividad Entre  Piscis Y  Acuarius
Comparatividad Entre Piscis Y Acuarius
 
Rezultate Eco-Scoala
Rezultate Eco-ScoalaRezultate Eco-Scoala
Rezultate Eco-Scoala
 

Semelhante a Deploy code easily with Git hooks

Getting started with git
Getting started with gitGetting started with git
Getting started with gitPawan Kumar.v
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneVEXXHOST Private Cloud
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How tolanhuonga3
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and GithubWycliff1
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developersmpvanwinkle
 
GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018Pooja Shah
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17siva ram
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!Cory Webb
 

Semelhante a Deploy code easily with Git hooks (20)

Getting started with git
Getting started with gitGetting started with git
Getting started with git
 
Github basics
Github basicsGithub basics
Github basics
 
3 Git
3 Git3 Git
3 Git
 
How To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub CloneHow To Install GitLab As Your Private GitHub Clone
How To Install GitLab As Your Private GitHub Clone
 
Git: Why And How to
Git: Why And How toGit: Why And How to
Git: Why And How to
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Git & github
Git & githubGit & github
Git & github
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018GIT workshop at Selenium Conference 2018
GIT workshop at Selenium Conference 2018
 
Git 1
Git 1Git 1
Git 1
 
GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17GIT_GITHUB_2016_06_17
GIT_GITHUB_2016_06_17
 
Git basics
Git basicsGit basics
Git basics
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git basics
Git basicsGit basics
Git basics
 
GitHub Event.pptx
GitHub Event.pptxGitHub Event.pptx
GitHub Event.pptx
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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 2024Results
 
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...Drew Madelung
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 DevelopmentsTrustArc
 
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 SolutionsEnterprise Knowledge
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 productivityPrincipled Technologies
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
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...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 

Deploy code easily with Git hooks

  • 2. Igor Santos Web developer ● From Rio de Janeiro, Brazil ● PHP Developer for ~6 years ● Ruby and JS Developer for fun ● Playing around with git for ~2 years slideshare.net/igorsantos07
  • 3. 0. Introduction ● Knows what Git is? ● Have ever used Git in the command line? ● Have ever deployed code? ○ How? SCP? WGet? ● Anyone developing in the production server?
  • 4. 1. Git Basics ● Commit: Saves changes with a description ● Pull: Get commits from a server ● Push: Send commits to a server ● Remotes ○ A remote machine that has a copy of the repository and accepts your commits ○ In a common centralized organization you usually have one, but it's possible to have many ○ Example: main repo is BitBucket or Google Code, mirrored to GitHub
  • 5. 2. Configure your server igor@local$ ssh santos@bluenose.cs.dal.ca password: ********** santos@bluenose$ mkdir repos santos@bluenose$ cd repos santos@bluenose$ pwd /users/cs/santos/repos santos@bluenose$ git clone «repo» myRep --bare This creates a clone of that repository that works just as another repository: with all administrative data, but not useable for development, as the code is not really checked in - just the Git meta-data. Take note
  • 6. igor@local$ cd dev/myCode igor@local$ git remote add prod ssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRep igor@local$ "Hi there!" > README.mkd igor@local$ git commit "+ Adding readme" igor@local$ git push prod 2. Configure your server Name given to the remote server Complete repository URL No line break!
  • 7. igor@local$ git commit "+ Adding readme" igor@local$ git push prod Q: OK, so... where's my README file? A: In the repository! Q: I can't see it. «not really a question» 2. Configure your server
  • 8. 3. Git Hooks ● 2 types: client and server hooks ● Client: ○ pre/post-commit ○ [prepare-]commit-msg ○ post-checkout, post-merge ● Server: ○ pre/post-receive Once per push ○ update Once per pushed branch http://git-scm.com/book/en/Customizing-Git-Git-Hooks
  • 9. 3. Git Hooks Simple copy $ cat hooks/post-receive #!/bin/sh GIT_WORK_TREE=/var/www/mysite git checkout -f Opposite of git clone --bare: copies the entire repository code, without git data. By default does that with the master branch, but you can use other options here as well. GIT_WORK_TREE tells git where it would copy stuff.
  • 10. 3. Git Hooks Complete deployment script https://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
  • 11. 4. Advanced ideas GitHub and other Git online repositories have options to do HTTP requests with code information after pushes, similar to post- receive hooks. This data can be used to trigger a deployment script in the server. There's also an online service called DeployHQ, where you can configure any repository (SVN/Git/Hg) and many deploy methods (FTP/SFTP/S3/Rackspace). It deploys new code using the chosen method.