Stop Using FTP: Atomic Git Deployments for Serious Web Projects
It is 2012. If you are still opening FileZilla, connecting to port 21 (or 22 if you have a conscience), and dragging a folder named v2_final_final from your desktop to a production server, you are doing it wrong.
I have seen entire e-commerce platforms go dark on a Friday night because a developer overwrote a config.php file with a local version pointing to localhost. FTP is prone to human error, it is slow, and it lacks version history on the server. There is no "undo" button when you overwrite a live library.
The solution is not to be more careful. The solution is Git-based deployment.
The Architecture of a Professional Deploy
Instead of pushing files manually, we treat the production server as just another Git remote. When you push to it, the server automatically checks out the latest code and updates the live web directory. This is often called an "atomic" deploy because files are updated almost instantly.
To do this, you need three things:
- Local Machine: Where you code.
- Origin (Optional): GitHub or Bitbucket (for backup/team code).
- Production Server: A VPS running Linux with SSH access.
Pro Tip: You cannot do this easily on cheap shared hosting. Most shared hosts jail your shell or deny execute permissions on scripts. You need a proper VPS with root access, like the KVM-based instances we provision at CoolVDS.
Step 1: Prepare the Server
Log in to your CoolVDS instance via SSH. We need to create a "bare" repository. A bare repo contains the version history but no working files—it's purely for synchronization.
ssh root@your-coolvds-ip
# Install git if you haven't yet
yum install git -y
# Create a directory for the repo
mkdir -p /var/git/project.git
cd /var/git/project.git
git init --bare
Step 2: The Magic Hook
Git has a mechanism called "hooks"—scripts that run when certain events happen. We care about post-receive, which fires after you successfully push code to the server.
We need to tell Git: "When code arrives here, force those files into the public web folder (e.g., /var/www/html)."
Create the hook file:
nano hooks/post-receive
Paste this Bash script:
#!/bin/bash
GIT_WORK_TREE=/var/www/html git checkout -f
chmod -R 755 /var/www/html
echo "Deployment to CoolVDS Production Complete."
Make it executable:
chmod +x hooks/post-receive
Step 3: Push to Deploy
Back on your local machine, add your new CoolVDS remote:
git remote add production ssh://root@your-coolvds-ip/var/git/project.git
Now, whenever you are ready to go live, you simply type:
git push production master
You will see the remote output in your local terminal confirming the checkout. No drag-and-drop. No missed files.
Why Infrastructure Matters
You might ask, "Why does the host matter for Git?"
1. Disk I/O: When Git checks out thousands of files, it hammers the disk. On a standard mechanical drive, a deploy can take 30-60 seconds, leaving your site in a limbo state. At CoolVDS, we use enterprise-grade SSD storage in RAID configurations. A git checkout of a Magento store takes milliseconds, not minutes.
2. Latency to NIX: If you are targeting Norwegian users, your server should be in Norway. Routing traffic through Frankfurt or London adds latency. CoolVDS peers directly at NIX (Norwegian Internet Exchange) in Oslo. This doesn't just make your website faster; it makes your SSH sessions snappy. There is nothing worse than typing a command and waiting 200ms for the character to appear.
3. Data Sovereignty: With the Data Protection Directive (95/46/EC) and the strict enforcement by Datatilsynet here in Norway, knowing exactly where your physical bytes reside is critical for compliance. Hosting on a cloud where data floats between US and EU datacenters is a legal liability waiting to happen.
The Verdict
Stop cowboy coding. Version control isn't just for code; it's for your deployment process. By moving to a Git-based workflow on a high-performance VPS, you eliminate the "oops" factor of FTP.
Ready to upgrade your workflow? Deploy a CentOS 6 SSD VPS on CoolVDS today and get root access in under 55 seconds. Your future self will thank you.