Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Push into Production (FTP)

Tags:

git

push

ftp

People also ask

Can you use git on FTP?

No, Git does not support a push to an FTP server, only clone and fetch.

How do I push to production on GitHub?

Create a Git Deploy key that allows pushing to your production Git server. Store the Git Deploy key in a secret on Semaphore. Create a deployment pipeline and attach the Git Deploy key secret. Run a deployment from Semaphore and ship your code to production.


Some tools recently added to the Git wiki:

git-ftp by René Moser is a simple shell script for doing FTP the Git way. Use git-ftp.sh to upload only the Git tracked files to a FTP server, which have changed since the last upload. This saves time and bandwith. Even if you play with different branches, git-ftp.sh knows which files are different. No ordinary FTP client can do that.

git-ftp by Edward Z. Yang is a simple script written in python for uploading files in a Git repository via FTP, only transferring new files and removing old files.


If you prefer GUI, use SourceTree, you can easily setup a Custom Action that uses git-ftp mentioned above. A brief description on setup (for Mac) at Push a Git repository to an FTP

enter image description here


I've found PHPloy a great tool for sending your Git commits to remote servers over FTP. It works from the command-line and is written in PHP (and even detects changes in submodules).

https://github.com/banago/PHPloy‎

git commit ...
phploy -s staging
phploy -s production

Done!

(Disclaimer: after using it for a while I've now contributed some code patches and improvements, making it Windows-compatible.)


If you're on a mac and have Transmit, I'd recommend the following git-tranmit script (https://gist.github.com/379750). It uses DockSend to send only the last updated files. If you're not familiar with DockSend, check out http://www.panic.com/blog/2010/11/15-secrets-of-transmit/.

Setup:

  1. cp git-transit /usr/sbin/.
  2. cd /usr/sbin
  3. chmod +x git-transmit
  4. Setup drop send for your live app
  5. Run git-transmit in your git repository.

That's not what git is for, strictly speaking. However, if your source is something that doesn't need compiling or processing, say a website consisting entirely of html and javascript files and the like, you could have a clone of the repo on your webserver and use git pull from the server to keep it up-to-date. Note, I would config your webserver to hide the git directory and such. And that's just the beginning of the security concerns.

If you have any sort of compiling or processing, you should start looking at Ant, Maven, BuildR, SBT, etc.