Deploy easily!with
Igor SantosWeb developer● From Rio de Janeiro, Brazil● PHP Developer for ~6 years● Ruby and JS Developer for fun● Playing ...
0. Introduction● Knows what Git is?● Have ever used Git in the command line?● Have ever deployed code?○ How? SCP? WGet?● A...
1. Git Basics● Commit: Saves changes with a description● Pull: Get commits from a server● Push: Send commits to a server● ...
2. Configure your serverigor@local$ ssh santos@bluenose.cs.dal.capassword: **********santos@bluenose$ mkdir repossantos@bl...
igor@local$ cd dev/myCodeigor@local$ git remote add prodssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRepigor@l...
igor@local$ git commit "+ Adding readme"igor@local$ git push prodQ: OK, so... wheres my README file?A: In the repository!Q...
3. Git Hooks● 2 types: client and server hooks● Client:○ pre/post-commit○ [prepare-]commit-msg○ post-checkout, post-merge●...
3. Git HooksSimple copy$ cat hooks/post-receive#!/bin/shGIT_WORK_TREE=/var/www/mysite git checkout -fOpposite of git clone...
3. Git HooksComplete deployment scripthttps://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
4. Advanced ideasGitHub and other Git online repositorieshave options to do HTTP requests with codeinformation after pushe...
4. Adv.ideasdeployhq.com
Upcoming SlideShare
Loading in …5
×

Deployment made easy with Git

1,032 views
830 views

Published on

Easily explaining how to build, test and deploy code to a production server using a Git repository and some scripts to be run by Git.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,032
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Deployment made easy with Git

  1. 1. Deploy easily!with
  2. 2. Igor SantosWeb developer● From Rio de Janeiro, Brazil● PHP Developer for ~6 years● Ruby and JS Developer for fun● Playing around with git for ~2 yearsslideshare.net/igorsantos07
  3. 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. 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 repositoryand accepts your commits○ In a common centralized organization you usuallyhave one, but its possible to have many○ Example: main repo is BitBucket or Google Code,mirrored to GitHub
  5. 5. 2. Configure your serverigor@local$ ssh santos@bluenose.cs.dal.capassword: **********santos@bluenose$ mkdir repossantos@bluenose$ cd repossantos@bluenose$ pwd/users/cs/santos/repossantos@bluenose$ git clone «repo» myRep --bareThis creates a clone of that repository that works just asanother repository: with all administrative data, but notuseable for development, as the code is not really checkedin - just the Git meta-data.Take note
  6. 6. igor@local$ cd dev/myCodeigor@local$ git remote add prodssh://santos@bluenose.cs.dal.ca:/users/cs/santos/repos/myRepigor@local$ "Hi there!" > README.mkdigor@local$ git commit "+ Adding readme"igor@local$ git push prod2. Configure your serverName given to the remote serverComplete repository URLNo line break!
  7. 7. igor@local$ git commit "+ Adding readme"igor@local$ git push prodQ: OK, so... wheres my README file?A: In the repository!Q: I cant see it. «not really a question»2. Configure your server
  8. 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 branchhttp://git-scm.com/book/en/Customizing-Git-Git-Hooks
  9. 9. 3. Git HooksSimple copy$ cat hooks/post-receive#!/bin/shGIT_WORK_TREE=/var/www/mysite git checkout -fOpposite of git clone --bare: copies the entire repositorycode, without git data. By default does that with the masterbranch, but you can use other options here as well.GIT_WORK_TREE tells git where it would copy stuff.
  10. 10. 3. Git HooksComplete deployment scripthttps://bitbucket.org/igorsantos07/calen-do/src/3fea92ee46c1/git-hooks/update
  11. 11. 4. Advanced ideasGitHub and other Git online repositorieshave options to do HTTP requests with codeinformation after pushes, similar to post-receive hooks. This data can be used totrigger a deployment script in the server.Theres also an online service calledDeployHQ, where you can configure anyrepository (SVN/Git/Hg) and many deploymethods (FTP/SFTP/S3/Rackspace).It deploys new code using the chosen method.
  12. 12. 4. Adv.ideasdeployhq.com

×