Interactive, globally-installable CLI that syncs a Google Drive folder to a local directory. Pulls Google Docs/Sheets down as Markdown/CSV, and can push new local .md files up to Drive (one-time handoff).
- Interactive menus (
gdrive-sync) for init/sync/status. - Non-interactive flags:
--pull,--push,--sync,init --folder-id,status. - Folder picker with Drive search + subfolder navigation.
- Global config at
~/.config/gdrive-sync/(credentials + token). - Local metadata at
.gdrive-sync/metadata.json(schema v3.0 with drive folder id/name/path). - Push support: scans for untracked
.md, converts to HTML → Google Docs, mirrors folder structure, then tracks like remote files.
- Python 3.13+ (project uses src layout)
uvpackage manager- Google Cloud project with Drive API + Sheets API enabled
- OAuth client credentials JSON (Desktop app)
uv tool install .
# creates ~/.local/bin/gdrive-sync (ensure it’s on PATH)If you prefer a venv:
uv venv
source .venv/bin/activate
uv pip install -e .# Check current installation
uv tool list
# Reinstall with the latest code
uv tool install --force .- In Google Cloud Console create OAuth client (Desktop) and download the JSON.
- Run:
gdrive-sync setup --credentials-file ./credentials.jsonThis copies the credentials to ~/.config/gdrive-sync/credentials.json and clears any cached token. The first authenticated command will open a browser to grant scopes:
drive.readonlydrive.filespreadsheets.readonly
From the directory you want to sync:
gdrive-sync # interactive init wizardYou’ll search for a Drive folder, drill into subfolders, confirm, and the tool will download all supported files while creating .gdrive-sync/metadata.json.
Non-interactive:
gdrive-sync init --folder-id=<drive_folder_id>gdrive-sync: Interactive status + menu (sync/pull/push/view details).gdrive-sync --pull: Download remote changes only.gdrive-sync --push: Upload new local.mdfiles only (one-time handoff).gdrive-sync --sync: Pull then push.gdrive-sync status: Show counts of remote new/changed/deleted and local untracked markdown.
- Any untracked
.mdunder the synced root is uploaded as a Google Doc, preserving relative folders by creating missing Drive folders. - After upload, the file is tracked with its Drive ID like any remote file.
- Drive remains source of truth: later pulls overwrite local edits to uploaded files.
- Global:
~/.config/gdrive-sync/{credentials.json, token.json, config.json} - Local (per repo):
.gdrive-sync/metadata.json
- “command not found”: ensure
~/.local/binis on your PATH or activate the venv. - Auth issues: delete
~/.config/gdrive-sync/token.jsonand rerun any command to re-auth. - Re-point to another Drive folder: rerun
gdrive-sync init --folder-id=...in the target directory (will refresh metadata and pull).
uv tool install .gdrive-sync setup --credentials-file ./credentials.json- In a new folder:
gdrive-sync→ init wizard completes and downloads files. - Remote edits show up with
gdrive-sync --pull. - New local
.mduploads withgdrive-sync --push. gdrive-syncshows interactive status/menu in an initialized folder.