3

I just started (barely) to somewhat understand and use git. I'm using github and cloud9 IDE.

I figured out how to save (commit and then push ?) files to the github repository...

question:

Is there a command that will upload (and overwrite) files from my git to my ftp server where my website is hosted?

I've checked this question, but I'm not sure I want a .git on my server (unless I can still run my site off it).

I've also checked this question, but I'm not sure I can install anything on my server.

Is this not as simple as I thought it would be?

Any help is much appreciated.

Community
  • 1
  • 1
d-_-b
  • 21,536
  • 40
  • 150
  • 256
  • What's wrong with having a `.git` on your server? – SLaks Sep 11 '12 at 14:52
  • Sorry, i didn't mean dont want the file...I just want to be able to 'refresh' my live files, not just refresh a .git file (clearly I dont' understand git yet hahah) – d-_-b Sep 11 '12 at 14:53

4 Answers4

5

Git is not an FTP client. But you could create a post-commit hook to do this. A git hook is a shell script which is executed with certain actions. You could use this to upload all of your source files to your FTP server when you do a commit. For more information about hooks, see:

http://www.kernel.org/pub/software/scm/git/docs/githooks.html

Philipp
  • 67,764
  • 9
  • 118
  • 153
3

If you are working on the commandline - use lftp to ftp your files to your host. lftp is highly scriptable and will allow you to add it to a post-commit hook if you so desire.

If you are using a gui - you can try filezilla or any number of other ftp clients to move your files to your server.

If this is a project that you want other to work on in the future, you can consider learning capistrano for automatic deployments and ease of releases.

Michael
  • 10,124
  • 1
  • 34
  • 49
2

As I mentioned in this answer, PHPloy is a great tool for sending your git changes to remote servers over FTP (you don't have to install anything on the server, which is great if you're on a shared web host). It works from the command line and is written in cross-platform PHP (and even detects changes in submodules).

https://github.com/banago/PHPloy

From your local development machine, you just type...

git commit ...
phploy -s stagingServer
phploy -s productionServer

Done!

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

Community
  • 1
  • 1
Simon East
  • 55,742
  • 17
  • 139
  • 133
0

Whether using OSX, you can consider this GUI-based pretty convenient workflow (I also use for some WordPress stuff): http://eppz.eu/blog/push-git-to-ftp/

enter image description here

Geri Borbás
  • 15,810
  • 18
  • 109
  • 172