Zeke Xiao

Zeke Xiao


Use git-ftp to synchronize Hugo to FTP.


Git-ftp is an ftp application that uses git as a version control system. It uploads only the files that have been changed in git, saving bandwidth and time.


For Debian-based systems, you can simply install it by running:

sudo apt install git-ftp

For other versions, you can find the specific installation instructions here: https://github.com/git-ftp/git-ftp/releases. Simply extract the files and run the application.


Adding Config

You can directly add the following configuration to the .git/config file in your git project:

    url = ftp.example.net
    user = ftp-user
    password = secr3t

Alternatively, you can use git commands to add the configuration:

git config git-ftp.url ftp.example.net
git config git-ftp.user ftp-user
git config git-ftp.password secr3t

Specific Config Parameters

git config git-ftp.url ftp://ftp.example.net:8010/path - FTP address

git config git-ftp.user ftp-user - FTP username

git config git-ftp.password secr3t - FTP password

git config git-ftp.syncroot path/dir - Local directory to sync

git config git-ftp.remote-root htdocs - Remote directory

For more information, you can refer to the manual.


To initialize the synchronization of all files, run:

git ftp init

After making changes and committing them in git, you can sync to the remote directory by running:

git ftp push

This will only upload the updated files by comparing them with the local git repository.

Syncing with Hugo

Originally, the blog was synced using Caddy + git + hugo. However, since it was inefficient to run only this program on the VPS, I moved it to a virtual host on Baidu Cloud, which only costs 30 yuan per year.

To sync, follow the steps mentioned above to add the ftp configuration. Then, remove the ./public directory from the .gitignore file. The git-ftp.syncroot path should be $PATH_TO_YOUR_HUGO/public. After generating the files in the public directory using hugo -E, commit the changes and use git ftp push to sync.

2019-9 Switched to typlog
2023-7 Switched to xlog.app

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.