git-ftp (1)
NAME
Git-ftp - Git powered FTP client written as shell script.
SYNOPSIS
git-ftp [actions] [options] [url]...
DESCRIPTION
This manual page documents briefly the git-ftp program.
Git-ftp is a FTP client using Git to determine which local files to upload or which files should be deleted on the remote host.
It saves the deployed state by uploading the SHA1 hash in the .git-ftp: ftp.log file. There is no need for Git (git-scm.org to be installed on the remote host.
Even if you play with different branches, git-ftp knows which files are different and only handles those files. No ordinary FTP client can do this and it saves time and bandwidth.
Another advantage is Git-ftp only handles files which are tracked with Git (git-scm.org
ACTIONS
- C]init]
-
Initializes the first upload to remote host.
- C]push]
-
Uploads files which have changed since last upload.
- C]catchup]
-
Uploads the .git-ftp: ftp.log file only.
We have already uploaded the files to remote host with a different program and want
to remember its state by uploading the .git-ftp: ftp.log file.
- C]show]
-
Downloads last uploaded SHA1 from log and hooks `git show`.
- C]log]
-
Downloads last uploaded SHA1 from log and hooks `git log`.
- C]add-scope <scope>]
-
Creates a new scope (e.g.
dev, production, testing, foobar).
This is a wrapper action over git-config.
See B]SCOPES] section for more information.
- C]remove-scope <scope>]
-
Remove a scope.
- C]help]
-
Prints a usage help.
OPTIONS
- C]-u [username]], C]--user [username]]
-
FTP login name.
If no argument is given, local user will be taken.
- C]-p [password]], C]--passwd [password]]
-
FTP password.
If no argument is given, a password prompt will be shown.
- C]-k [[user]@[account]]], C]--keychain [[user]@[account]]]
-
FTP password from KeyChain (Mac OS X only).
- C]-a], C]--all]
-
Uploads all files of current Git checkout.
- C]-A], C]--active]
-
Uses FTP active mode.
- C]-s [scope]], C]--scope [scope]]
-
Using a scope (e.g.
dev, production, testing, foobar).
See B]SCOPE] and B]DEFAULTS] section for more information.
- C]-l], C]--lock]
-
Enable remote locking.
- C]-D], C]--dry-run]
-
Does not upload or delete anything, but tries to get the .git-ftp: ftp.log file from
remote host.
- C]-f], C]--force]
-
Does not ask any questions, it just does.
- C]-n], C]--silent]
-
Be silent.
- C]-h], C]--help]
-
Prints some usage information.
- C]-v], C]--verbose]
-
Be verbose.
- C]-vv]
-
Be as verbose as possible.
Useful for debug information.
- C]--remote-root]
-
Specifies remote root directory
- C]--syncroot]
-
Specifies a local directory to sync from as if it were the git project root path.
- C]--key]
-
SSH Private key file name.
- C]--pubkey]
-
SSH Public key file name.
Used with --key option.
- C]--insecure]
-
Don[aq]t verify server[aq]s certificate.
- C]--cacert <file>]
-
Use as CA certificate store.
Useful when a server has got a self-signed certificate.
- C]--disable-epsv]
-
Tell curl to disable the use of the EPSV command when doing passive FTP transfers.
Curl will normally always first attempt to use EPSV before PASV, but with this
option, it will not try using EPSV.
- C]--version]
-
Prints version.
URL
The scheme of an URL is what you would expect
-
C] protocol://host.domain.tld:port/path ]
Below a full featured URL to I]host.example.com] on port I]2121] to path I]mypath] using protocol I]ftp]:
-
C] ftp://host.example.com:2121/mypath ]
But, there is not just FTP. Supported protocols are:
- C]ftp://...]
-
FTP (default if no protocol is set)
- C]sftp://...]
-
SFTP
- C]ftps://...]
-
FTPS
- C]ftpes://...]
-
FTP over explicit SSL (FTPES) protocol
DEFAULTS
Don[aq]t repeat yourself. Setting defaults for git-ftp in .git/config
-
C] $ git config git-ftp.<(url|user|password|syncroot|cacert)> <value> ]
Everyone likes examples:
-
C] $ git config git-ftp: ftp.user john $ git config git-ftp: ftp.url ftp: ftp.example.com $ git config git-ftp: ftp.password secr3t $ git config git-ftp: ftp.syncroot path/dir $ git config git-ftp: ftp.cacert caCertStore $ git config git-ftp: ftp.deployedsha1file mySHA1File $ git config git-ftp: ftp.insecure 1 $ git config git-ftp: ftp.key ~/.ssh/id_rsa ]
After setting those defaults, push to I]john@ftp.example.com] is as simple as
-
C] $ git ftp push ]
SCOPES
Need different defaults per each system or environment? Use the so called scope feature.
Useful if you use multi environment development. Like a development, testing and a production environment.
-
C] $ git config git-ftp.<scope>.<(url|user|password|syncroot|cacert)> <value> ]
So in the case below you would set a testing scope and a production scope.
Here we set the params for the scope "testing"
-
C] $ git config git-ftp: ftp.testing.url ftp: ftp.testing.com:8080/foobar-path $ git config git-ftp: ftp.testing.password simp3l ]
Here we set the params for the scope "production"
-
C] $ git config git-ftp: ftp.production.user manager $ git config git-ftp: ftp.production.url live.example.com $ git config git-ftp: ftp.production.password n0tThatSimp3l ]
Pushing to scope I]testing] alias I]john@ftp.testing.com:8080/foobar-path] using password I]simp3l]
-
C] $ git ftp push -s testing ]
I]Note:] The B]SCOPE] feature can be mixed with the B]DEFAULTS] feature. Because we didn[aq]t set the user for this scope, git-ftp uses I]john] as user as set before in B]DEFAULTS].
Pushing to scope I]production] alias I]manager@live.example.com] using password I]n0tThatSimp3l]
-
C] $ git ftp push -s production ]
I]Hint:] If your scope name is identical with your branch name. You can skip the scope argument, e.g. if your current branch is "production":
-
C] $ git ftp push -s ]
You can also create scopes using the add-scope action. All settings can be defined in the URL. Here we create the I]production] scope using add-scope
-
C] $ git ftp add-scope production ftp://manager:n0tThatSimp3l@live.example.com/foobar-path ]
Deleting scopes is easy using the C]remove-scope] action.
-
C] $ git ftp remove-scope production ]
IGNORING FILES TO BE SYNCED
Add file names to C].git-ftp-ignore] to be ignored.
Ignoring all in Directory C]config]:
-
C] config/.* ]
Ignoring all files having extension C].txt] in C]./] :
-
C] .*\.txt ]
This ignores C]a.txt] and C]b.txt] but not C]dir/c.txt]
Ignoring a single file called C]foobar.txt]:
-
C] foobar\.txt ]
SYNCING UNTRACKED FILES
To upload an untracked file when a paired tracked file changes (e.g. uploading a compiled CSS file when its source SCSS or LESS file changes), add a file pair to C].git-ftp-include]:
-
C] css/style.css:scss/style.scss ]
If you have multiple source files being combined into a single untracked file, you can pair the untracked file with multiple tracked files, one per line. This ensures the combined untracked file is properly uploaded when any of the component tracked files change:
-
C] css/style.css:scss/style.scss css/style.css:scss/mixins.scss ]
NETRC
In the backend, Git-ftp uses curl. This means C]~/.netrc] could be used beside the other options of Git-ftp to authenticate.
-
C] $ editor ~/.netrc machine ftp: ftp.example.com login john password SECRET ]
EXIT CODES
There are a bunch of different error codes and their corresponding error messages that may appear during bad conditions. At the time of this writing, the exit codes are:
- C]1]
-
Unknown error
- C]2]
-
Wrong Usage
- C]3]
-
Missing arguments
- C]4]
-
Error while uploading
- C]5]
-
Error while downloading
- C]6]
-
Unknown protocol
- C]7]
-
Remote locked
- C]8]
-
Not a Git project
KNOWN ISSUES & BUGS
The upstream BTS can be found at <github.com/git-ftp/git-ftp/issues>.