Live data from Hacker News

Ask HN: How do you push your code to your server?

news.ycombinator.com

1–10 of 22 posts

Ask HN: How do you push your code to your server?

#1
Most people write code on localhost then push to servers after testing. How do you do the second part? I've heard of git push, rsync, ftp, etc. I also know some people who just edit the code directly on the server over ssh.

What do you do? And how often do you push out code-- every few lines, or every hundred lines, etc.?

Re: Ask HN: How do you push your code to your server?

#2
We do everything on localhost with git. We keep a master (server) and develop (ready to push to master) and with develop we branch it off into different major features i.e. feature/login, etc. Once the branches are ready we push them into develop to bug test and when all's good we push the changes to master. We only push to master when the code has been somewhat significantly changed like adding a new feature or fixing bugs.

Re: Ask HN: How do you push your code to your server?

#3
git push staging master

or git push staging dev:master

>just edit the code directly on the server over ssh.

Don't do that unless it is a horrible bug fix. Like a security vuln you need to push immediately. Take the extra time to put it into dev or whatever and then push / upload it to wherever.

>I've heard of git push, rsync, ftp, etc.

This really depends on what I'm doing. Obviously if I'm pushing to Heroku it is Git, but I also help out some local folk with the website about their farm fresh eggs. For the latter it is just FTP, because nothing more is necessary. (I I guess I do use a static site generator similar to http://jekyllrb.com/)

Re: Ask HN: How do you push your code to your server?

#4
I've got a few different approaches for deployments.

For static sites, which are built from templates, or by hand, I just deploy via rsync. This is nice and efficient, and is carried out over SSH which allows me to be secure in-transit and avoid having to enter passwords.

For dynamic applications I've tended to write simple recipes via fabric (http://fabfile.org/) which allows me to bundle up the local state of a repository, transfer it over SSH, and run a few commands.

For some things in the middle I use git pushes to different environments, but I'm trying to move away from that and into more scripted deployment via ansible, fabric, slaughter, etc.

Re: Ask HN: How do you push your code to your server?

#5
>I also know some people who just edit the code directly on the server over ssh.

I've edited js directly over sftp sometimes. But it was for a service for which the choices were ftp or a web editor which I refuse to use, on test pages. For Wordpress I have local installs of each site and a development install just for plugins, and I usually keep a backup on bitbucket and a test deploy on pagodabox.

>And how often do you push out code-- every few lines, or every hundred lines, etc.?

Not very often. Some of my personal projects can go months without so much as a look.

Re: Ask HN: How do you push your code to your server?

#8
This is just for my personal site (wordpress), and probably isn't relevant for a webapp at scale:

a fabric script + git/Github

I develop on localhost and use a python script (with fabric) to manage deployment with git

>>fab git_commit: changes all the Wordpress url references in the database from localhost to production url, dumps the database, uses sed to replace localhost with production url in a few other files, and runs git commit.

>>fab deploy: pushes local repo to private Github repository, runs git pull on production server, and updates the production database from the database dump in the repo.

Re: Ask HN: How do you push your code to your server?

#10
Here's what I do

1. Develop locally, use Github/Bitbucket for version control

2. ssh into my vps and use git pull

3. Configure things like api secrets (ssh + vim)

If there is a bug that needs to be fixed, go back to local, fix, push, ssh, pull, deploy

[update] Formatting changes

Post reply on HN