Git Product home page Git Product logo

git-ftp's Introduction

git-ftp.py: quick and efficient publishing of Git repositories over FTP

Introduction

Some web hosts only give you FTP access to the hosting space, but you would still like to use Git to version the contents of your directory. You could upload a full tarball of your website every time you update but that's wasteful. git-ftp.py only uploads the files that changed.

Requirements: git-python 0.3.x
it can be installed with easy_install gitpython

We also have a PPA which you can install with sudo add-apt-repository ppa:niklas-fiekas/ppa and then sudo aptitude install git-ftp.

Usage: python git-ftp.py

Note: If you run git-ftp.py for the first time on an existing project you should upload to the hosting server a git-rev.txt file containing SHA1 of the last commit which is already present there. Otherwise git-ftp.py will upload and overwite the whole project which is not necessary.

Storing the FTP credentials

You can place FTP credentials in .git/ftpdata, as such:

[master]
username=me
password=s00perP4zzw0rd
hostname=ftp.hostname.com
remotepath=/htdocs
ssl=yes

[staging]
username=me
password=s00perP4zzw0rd
hostname=ftp.hostname.com
remotepath=/htdocs/staging
ssl=no

Each section corresponds to a git branch. FTP SSL support needs Python 2.7 or later.

Exluding certain files from uploading

Similarly to .gitignore you can specify files which you do not wish to upload. The default file with ignore patterns is .gitftpignore in project root directory, however you can specify your own for every branch in .git/ftpdata:

[branch]
... credentials ...
gitftpignore=.my_gitftpignore

Used syntax is same as .gitignore's with the exception of overriding patterns, eg. **!**some/pattern, which is not supported Negations within patterns works as expected.

Using a bare repository as a proxy

An additional script post-receive is provided to allow a central bare repository to act as a proxy between the git users and the ftp server.
Pushing on branches that don't have an entry in the ftpdata configuration file will have the default git behavior (git-ftp.py doesn't get called). One advantage is that users do not get to know the ftp credentials (perfect for interns).
This is how the workflow looks like:

User1 --+                          +--> FTP_staging
         \                        /
User2 -----> Git bare repository -----> FTP_master
         /                        \
User3 --+                          +--> FTP_dev

This is how the setup looks like (One ftpdata configuration file, and a symlink to the update hook):

root@server:/path-to-repo/repo.git# ls
HEAD  ORIG_HEAD  branches  config  description  ftpdata  hooks  info  objects  packed-refs  refs
root@server:/path-to-repo/repo.git# ls hooks -l
total 0
lrwxr-xr-x 1 root    root      29 Aug 19 17:17 post-receive -> /path-to-git-ftp/post-receive

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

git-ftp's People

Contributors

dl1ely avatar ezyang avatar micahchalmer avatar msiemens avatar niklasf avatar nviennot avatar patriksima avatar peteruhnak avatar ramblex avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.