Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Instant Deployment with Git

DZone's Guide to

Instant Deployment with Git

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

One of the nicest things in git is that you can actually deploy code to production (or just your test environment) w/o implementing a complicated CI solution.

Off course that using CI such as Jenkins is recommended when compilation is required (JAVA/C/C++/C#) or when TDD/unit tests are use (and you better use them).
Yet, when you just need to deploy, git can be a great service for you.

Note: please note that you must an ssh access from the local machine (not always feasble).

How is done?
Actually it is very simple (and a complete explenation can be found atstackoverflow and toroid):


Step #1: Setup a repository in the development environment and commit a first file
> git init
Step #2: Setup an environment at the web server
> mkdir /path/to/dir/website.git && cd /path/to/dir/website.git
> git init --bare

Step  #3: Enable a post receive hook at the web server
> mkdir /var/www/www.mydomain.com
> cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.mydomain.com git checkout -f
> chmod +x hooks/post-receive
Step  #4: Create a trigger at the  development environment  (and why you need ssh access from the workstation).
> git remote add web ssh://www.mydomain.com/path/to/dir/website.git
> git push web +master:refs/heads/master
Step  #5: Code, Commit and Push to production
> echo 'Rocking website!' > index.html
> git add index.html
> git commit -q -m "The index file was commited"
> git push web

Bottom Line
It is a simple task, but tricky if you don't have a direct access to the server (anyone said Jenkins?)

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:

Published at DZone with permission of Moshe Kaplan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}