Upload only the files that have changed in your Git repository to an FTP server.
No more uploading entire projects – just the differences. Remote directories are created automatically.
- 🔍 Smart file detection – Uses
git statusto find modified, staged, and untracked files. - 📁 Auto‑directory creation – Missing remote folders are created on the fly.
- 🗑️ Remote deletion – Deletes files on the server that were removed locally (optional).
- 🛡️ Dry‑run mode – See what would happen without touching your FTP server.
- ✅ Skip confirmation – For CI/CD or scripting (
--yes). - 🔐 Credentials safety – Config file is separate, add it to
.gitignoreto prevent leaks.
- Python 3.6 or newer
- Git (must be installed and accessible in your PATH)
git clone https://github.com/rafiz001/git_ftp_sync.git
cd git_ftp_syncCreate a file named ftp_config.json next to the script (or pass a custom path with --config).
{
"host": "ftp.example.com",
"port": 21,
"user": "myuser",
"password": "mypassword",
"remote_base": "/public_html",
"use_tls": false
}| Field | Description |
|---|---|
host |
FTP server hostname or IP address |
port |
FTP port (default: 21) |
user |
FTP username |
password |
FTP password |
remote_base |
Remote root path where files will be uploaded (e.g. /public_html) |
use_tls |
Set to true to use FTP over TLS (FTPS) |
Add ftp_config.json to your .gitignore to prevent accidental commits:
echo "ftp_config.json" >> .gitignoreRun the script from inside your Git repository (the script automatically detects the repo root).
python git_ftp_sync.pyBy default, it will:
- Show a summary of files to upload / delete.
- Ask for confirmation before proceeding.
| Option | Description |
|---|---|
--config FILE |
Use an alternative config file (default: ftp_config.json) |
--dry-run |
Print what would be uploaded/deleted without making any FTP changes |
--no-delete |
Upload only; do not delete files on the server even if removed locally |
--yes, -y |
Skip the confirmation prompt (useful for automated scripts) |
# Preview changes without uploading
python git_ftp_sync.py --dry-run
# Upload immediately without asking
python git_ftp_sync.py --yes
# Only upload new/modified files, never delete anything
python git_ftp_sync.py --no-delete
# Use a different config file
python git_ftp_sync.py --config /path/to/ftp_config.json- The script runs
git status --porcelain=v1 --untracked-files=allto get a list of changed files. - It distinguishes between modified (including new/untracked) and deleted files.
- For each modified file, it uploads it to the remote path:
remote_base + local_path. - If deletion is enabled, it removes files on the server that are deleted locally.
- Missing remote directories are created recursively before each upload.
| Problem | Solution |
|---|---|
git not found |
Install Git and ensure it's in your PATH. |
Not inside a git repository |
Run the script from within a Git repository. |
Config file not found |
Create ftp_config.json or provide the path with --config. |
| FTP connection errors (timeout, auth) | Verify your FTP credentials and network connectivity. |
550 errors when creating directories |
The directory may already exist; these are ignored and the upload continues. |
| Files are not being detected | Check if .gitignore excludes them. The script only sees files tracked by Git. |
This project was created with the assistance of Claude AI (Anthropic).
Claude helped design the architecture, write the code.
This project is open‑source and available under the MIT License.
Feel free to open an issue or pull request on GitHub.
All contributions are welcome!
Happy syncing! 🚀