22

Git FTP for Windows

Why are we still using FTP?

If you are using a shared host like GoDaddy, Asmallorange etc. they have limited options when it comes to uploading your code to their servers. Most will provide only FTP access. If you are using Git (or GitHub) for your development purpose, it becomes a huge inconvenience to use an FTP client to upload the files manually. If you have a large set of files, then you also need to manually upload only the changed files.

With this solution, you will not need to use an FTP client.

Step 1

Begin with downloading msysgit for Windows. At the time of writing this, the latest file is “msysGit-fullinstall-1.8.4-preview20130916.exe”. Click on the link below to download.

Download msysgit

When prompted, extract to “c:\” and this will create a “c:\msysgit” folder. It may take a while to download and install.

Step 2

On completion, it will launch c:\msysgit\msys.bat (you can run it manually if it doesn’t). Then simply run the following commands one-by-one:

cd ~
git clone https://github.com/git-ftp/git-ftp git-ftp.git
cd git-ftp.git && chmod +x git-ftp
cp ~/git-ftp.git/git-ftp /bin/git-ftp

Git FTP

On completion, close this window and create a shortcut to “c:\msysgit\git-cmd.bat” (Note this is different from msys.bat)

The Workflow

Committing Changes

I use GitHub so I prefer using their simple tool for committing changes. You can use the command-line version as well if you need more control. If you need a good guide to learn Git, I suggest:

Easy version control with Git

Pushing to FTP

1. Simply launch git-cmd.bat
2. This will load a standard command prompt. Go to your working folder (which you want to synchronize) [must be git repo].
3. For the first time, add your FTP details

git config git-ftp.user demouser
git config git-ftp.url ftp.example.com/demofolder
git config git-ftp.password demopassword

4. To initialize, run the following command for your first commit only

git ftp init

5. After this, for all subsequent commits

git ftp push

That’s all folks!


Discuss, Share & Subscribe

Do let me know your suggestions on how I can improve this tutorial. If you like what you are reading, then please help spread the word by re-tweeting, blogging and sharing this tutorial. Thank you.


398 Words
11110 Views