[RFC] git-remote-seafile: Transparent Git Remote Helper for Seafile (No sync churn, Git LFS, distributed locking)

Hi,

For years, developers using Seafile have tried to sync active software repositories across machines by storing working directories directly inside synced libraries. As many of us have experienced firsthand, this causes severe friction:

  1. Sync Client Thrashing: A single git commit touches 15+ files inside .git/ in milliseconds, triggering hundreds of continuous library re-index cycles per day (over 1,500+ cycles/day observed in active repos).

  2. Lock Contention: Ephemeral lock files like .git/index.lock sync across machines, freezing Git operations on secondary computers.

  3. Conflict Storms: Diverging branches cause Seafile to generate hundreds of (SFConflict ...) duplicate files rather than allowing Git to perform 3-way line merges.

  4. Ignore Limitations: .seafile-ignore.txt cannot ignore folders retroactively, must sit at library root, and amputates .git/ from secondary machines if used.

To solve this properly without requiring developers to deploy and maintain a separate Git server stack (like GitLab or Gitea), I have built git-remote-seafile—a transparent, zero-thrash Git remote helper for Seafile.

How It Works

Instead of placing local working repositories inside synced folders, developers keep their code in normal un-synced folders (e.g. C:\code\myproject or ~/code/myproject).

git-remote-seafile implements the official git-remote-helpers(7) protocol and speaks directly to the Seafile Web API v2.1 over HTTP/HTTPS:


# Push directly to any Seafile library as an authentic Git remote:

git remote add origin seafile://code/myproject

git push -u origin main

# Clone on another workstation:

git clone seafile://seafile.example.com/code/myproject

Key Capabilities & Guarantees

  • Atomic Packfile Transport: Commits are bundled into native Git packfiles (.pack and .idx) before upload. Pushing 100 commits uploads only 1–2 files, resulting in sub-second pushes (<1s) and zero desktop daemon scanning.

  • Fast-Forward Safety & Conflict Elimination: Non-fast-forward pushes are rejected unless force-pushed. Standard Git pull/rebase handles merging; no (SFConflict ...) files can ever be generated.

  • Distributed Lease Locking: Pushes acquire an advisory lease on .git-lock.json on Seafile with auto-expiration (60s), preventing race conditions without risk of deadlocks from crashed clients.

  • Git LFS Integration: Implements the official Git LFS Custom Transfer Agent protocol (lfs-transfer), allowing multi-gigabyte models, datasets, or video assets to stream into Seafile storage.

  • Remote Packfile Compaction & Auto-GC (gc): Re-packs accumulated remote packs, delta-compresses history, and automatically prunes unreachable commits from rolled-back branches.

  • Zero-Config Auth: Automatically detects active logins from Windows, macOS, Linux, and seaf-cli local desktop client SQLite databases (accounts.db), or falls back to ~/.git-seafile.json / environment variables.

  • Production-Grade Test Suite: Includes 38 automated unit tests with full CI across Windows, Linux, and macOS (Python 3.8–3.14).

Proposal to Haiwen / Upstream Integration

I would love to upstream this project into the official Seafile ecosystem:

  1. Host under the official organization as haiwen/git-remote-seafile (or bundle within the client distribution).

  2. Distribute via PyPI and package with Seafile desktop installers.

  3. Integrate a context-menu option in the Seafile desktop client (“Copy Git Remote URL”, patch ready in repo).

Feedback, suggestions, and thoughts from the maintainers and community are warmly welcome!

This sounds interesting. We will give it a check soon.

The repo has been massively updated and reviewed by a few AIs. It should be production ready. Kindly check it out if you haven’t done so. ^^

Really cool feature, I use it heavily already.