Git Push into Production (FTP)

GitFtpPush

Git Problem Overview


I would like to know if there is an easy way to push a GIT repository into production (on a FTP server) ? Thanks

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Solution 3 - Git

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.)

Solution 4 - Git

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.

Solution 5 - Git

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.

Solution 6 - Git

You could use Deployhq.com it works like a charm, the only thing you need to do is to set up your repository and FTP account.

They currently the following version control systems:

Git, Subversion, Mercurial.

With repository hosted

  • GitHub
  • Bitbucket
  • GitLab
  • Codebase

enter image description here

Solution 7 - Git

This is a script in PHP to upload almost automatically the git-diff to a FTP server:

http://code.google.com/p/upload-git-diff-with-ftp/

Solution 8 - Git

https://www.deployhq.com/

Free for one project and it works very very well.

Solution 9 - Git

There's a Ruby script here - Ruby git-deploy via FTP or SSH which uploads only the changed files in the git repo via FTP or SSH.

As mentioned in another answer, here is the Python git-ftp.py script which does a similar thing.

And here is the shell script version of git-ftp.

There is also a Ruby gem project called git-deploy which lets you setup a custom deploy via a git remote using the git push command, in the same way as the Heroku and Azure services. For this one you may need to write custom methods to deploy via FTP and I think it assumes you have SSH access to your production server.

Solution 10 - Git

If you are putting code into production, I recommend using an "installer" such as an RPM package to install your code. That way it will be version stamped and you will be able to leverage the installer package to support updates to the production code. Git is not really designed to support production installations, it is intended to track changes to the code itself.

In any event, with an .RPM (or EXE or whatever) built, you can just FTP it to the production system and install it like any other package.

Solution 11 - Git

Add it as a remote, then you can push to it, however simply pushing code isn't enough, it needs to be merged with the working tree. The easiest way is to go the other way round, have a working tree on the server and fetch and merge into that.

Solution 12 - Git

You can always try to mount the ftp to a local directory using http://linuxconfig.org/mount-remote-ftp-directory-host-locally-into-linux-filesystem.

Then you can use it the same way as this.

Solution 13 - Git

I was struggling a lot to figure out this. I have figured out an easy way to get this done from various sources (git-ftpINSTALL, git-ftpUPLOAD, git-ftpIssue, git-ftpPUSH). You can read for reference but there is no need because I have mentioned step by step process below.

First thing first: Install git and curl using brew on MAC OS

brew install git
brew install curl --with-ssl --with-libssh2
brew install git-ftp

Run the following commands:

git clone https://github.com/git-ftp/git-ftp.git
cd git-ftp
git tag # see available tags
git checkout <tag> # checkout the latest tag by replacing <tag>
sudo make install

Updating using git

git pull
git tag # see available tags
git checkout <tag> # checkout the latest tag by replacing <tag>
sudo make install

Setup

git config git-ftp.url YourFtpServerName.Net
git config git-ftp.user FtpUserName
git config git-ftp.password YourPassword

Upload all files

git ftp init

Or if the files are already there

git ftp catchup

Work and deploy

echo "Hello StackOverflow" >> index.txt
git commit application/libraries/index.txt -m "I love StackOverflow"
git ftp push

If there is an error: pathspec 'index.txt' did not match any file(s) known to git. It means the file hasn't been staged yet, so add the file and then try commit.

git add application/libraries/index.txt
git commit application/libraries/index.txt -m "I love StackOverflow"

Hope this helps.

Solution 14 - Git

You can try FTPloy ...

https://ftploy.com

> "Push changes to GitHub or Bitbucket." > > "Deploy Changes automatically to your server"

You have one free project to try it out with. I am currently using for a small php website and it works quite well. A few bugs on the site but its an active project so at least they are working on it.

Solution 15 - Git

Check out https://gitftp-deploy.com/ if you're on MacOS and you like GUIs.

It is a nice little application that uses Git to track changes and upload only the changed files with FTP.

Especially handy if you don't like paying monthly fees for dozens of smaller projects with small teams.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRochView Question on Stackoverflow
Solution 1 - GitTim HeniganView Answer on Stackoverflow
Solution 2 - GitGeri BorbásView Answer on Stackoverflow
Solution 3 - GitSimon EastView Answer on Stackoverflow
Solution 4 - GitRob SawyerView Answer on Stackoverflow
Solution 5 - GitsblundyView Answer on Stackoverflow
Solution 6 - GitJoel Meza BacaView Answer on Stackoverflow
Solution 7 - GitMarco AntonioView Answer on Stackoverflow
Solution 8 - GitDave ThompsonView Answer on Stackoverflow
Solution 9 - Gitdodgy_coderView Answer on Stackoverflow
Solution 10 - GitJustin EthierView Answer on Stackoverflow
Solution 11 - Gitd11wtqView Answer on Stackoverflow
Solution 12 - GitPyRulezView Answer on Stackoverflow
Solution 13 - GitSdemblaView Answer on Stackoverflow
Solution 14 - GitDave ThompsonView Answer on Stackoverflow
Solution 15 - GitbramchiView Answer on Stackoverflow