DLH
DLH

Reputation: 2821

Should I use Git for deployment of web apps?

I use Git to track local changes in my PHP web applications, and I was wondering if it would be a good idea to use Git on the server as well, so that I could just use git push to deploy my changes. Would there be any pitfalls with this approach?

Upvotes: 11

Views: 2176

Answers (6)

Ken Struys
Ken Struys

Reputation: 1789

Git is fine but you can do a lot better then just using git pull. Take a look at railess deploy for capistrano.

Capistrano basically does a combination of rsync and git pull to deploy copies of your website. It supports roleback, staging and distributed deployments.

Upvotes: 2

Bob Fanger
Bob Fanger

Reputation: 29897

And online hotfixes can be pushed back to development.
Being able to do a git status on a live system can be a live saver.

Go for it!

Caveats

  • Make sure the the ".git" folder isn't accessible from the web.
  • With PHP the source code is usually present on the webserver, so that doesn't add additional risk in case the server is hacked.

Upvotes: 1

Aardvark
Aardvark

Reputation: 1264

I think its a great solution. I have been using it to deploy my website for a long time... Its nice because you can almost instantly push your changes into production just by updating the folder. I have encountered no security issues or anything with it.

Enjoy!

Upvotes: 0

Bill Karwin
Bill Karwin

Reputation: 562230

I would be in favor of using a technique like this if only because you can be sure anything on your deployed site is also being tracked in git. That is, it encourages a best practice and discourages ad hoc changes that aren't under source control.

For another alternative, check out this article about how Twitter uses BitTorrent to manage deployment: http://torrentfreak.com/twitter-uses-bittorrent-for-server-deployment-100210/ It's probably most useful when you need to deploy quickly across a large collection of servers.

Upvotes: 0

signine
signine

Reputation: 3113

This seems like a nice way to do things. If you're tagging and branching properly it will enable you to quickly switch back to working versions of your site too in the event that something breaks.

Upvotes: 5

GSto
GSto

Reputation: 42350

I think this is a fine way to do it. I handle things in a similar manner, where live sites are just a checkout from the repository, and i update them as necessary.

Upvotes: 4

Related Questions