How to deploy code using git
I have a bare repository initialize on my webserver. I code on my workstation and I'm able to push/pull/commit changes to it. Now, I want to deploy this code on the webserver but into my apache directory (/var/www/html). If I wanted to track the changes (only pull no push) from this directory, should I clone the repo first?
This way I can make changes locally, then commit and push to "central repo" and then pull from the documentroot folder to see the 开发者_高级运维changes in "prod."
I think the keyword you're looking for is "continuous integration". There are tons that are geared for SVN but GIT is new so it's slowly rolling out. I use CruiseControl.NET for my .NET projects and it's a dream!
I don't know the technology your projects are in but for GIT Hudson comes to mind. Link to Hudson GIT plugin: http://wiki.hudson-ci.org/display/HUDSON/Git+Plugin
Good Luck! Hope this helps
If you want to do it without mucking with Ruby on Rails or just want to keep it simple, I suggest checking out http://more.zites.net/git_deploy_code_changes
I'm running into the same thing as you and this worked for me best.
Check out git-deploy - combined with SSH keys it's a wonderful lightweight solution for easy deployment.
I blend this with git-flow to deploy dev builds to stage & release builds to production in a well organized/controlled way.
You might want to check out what I learned here about securely deploying a git project to a remote webserver without exposing your repo to your webserver: https://stackoverflow.com/a/18941021/470749
I found it more lightweight to set up than something like Hudson or Jenkins.
I ended up using git clone and then pulling changes from the repo.
git is not quite suitable for deployment. I suggest writing your own deployment scripts, or using a tool like capistrano.
See: http://www.capify.org/index.php/Capistrano
精彩评论