1

I can't find any good explanation of how to use git to get a site to staging / live servers.

At the moment i've ssh'd into the server and cloned my bitbucket repo into there and checked out the master branch. It works, but is this the best way?

I'm pretty new to git and server stuff so trying to get my head around it all.

khr055
  • 26,892
  • 16
  • 34
  • 47
markstewie
  • 8,317
  • 8
  • 46
  • 69

3 Answers3

1

The basic idea is to add a post receive hook on your server, as explained here: Git Post-Receive Hook for Website Staging

Community
  • 1
  • 1
Dor Shemer
  • 20,782
  • 2
  • 25
  • 29
0

Depending on the site and how its built, yes, simply using Git to update to the latest stable version (or any version) is a perfectly fine way to "deploy" a simple website.

As the site gets more complex and has more dynamic components to it, and depending on the framework it's built on, more than a simple update may be needed, but it's 100% dependent on the specific site.

cdeszaq
  • 29,170
  • 25
  • 111
  • 169
0

I use git archive and Chef.

My process:

  • Tag release in git
  • git archive <tag_name> | gzip > <release_name>.tar.gz
  • upload the zipped file to a staging location
  • unzip source code to production server

My chef recipe handles the last two steps this way:

  • mv <release_name>.tar.gz into the files directory for my chef cookbook
  • upload chef cookbook
  • recipe copies the file to a cache and then unzips it
lhagemann
  • 1,262
  • 11
  • 13