Half-day migration: moving 9,263 images out of Git

On October 17, 2026, a developer posted on Juejin: the GPT Image prompt site 生图灵感库 moved all its sample images to Cloudflare R2. The entire architecture upgrade was assisted by GPT-6.1 (the author notes using the Sol model with reasoning effort turned down) for writing scripts, troubleshooting, and validation, and took about half a day.
- Scale: 5,513 asset sets, 9,263 images, about 1.78 GB
- Result: local .git shrank from about 2.8 GB to about 68 MB, a reduction of about 97.6%
- Delivery: images are now served from a separate domain, prompts-img.wangruofeng007.com; pages and prompt data are still published on GitHub and Workers Static Assets
- Publishing flow: everything goes through
node scripts/prepare-publish.mjs—first validate newly added local images, then incrementally upload to R2, and only after that build the pages - Availability: the site is live and accessible; this is a personal project and does not involve model weights or paid tiers
R2 is Cloudflare’s object storage service, best understood as “a cloud drive for files only,” billed and rate-limited separately from Workers, which serves the pages.
The starting point was a failed deployment: 20,379 assets hit the 20,000 limit

Originally, images and code were pushed to GitHub together, and a single commit captured the relationship between pages, prompts, and sample images; the pipeline was very short. As images multiplied, the repo grew heavier: switching to another computer for development meant cloning the entire repo first, and deployments also had to handle a large number of files that could have been distributed independently.
The real trigger was a failed launch. The author first suspected GitHub hadn’t triggered deployment; checking the build record showed it had triggered fine but was stuck at the asset upload stage—the log showed 20,379 resources pending deployment, exceeding the Workers Free limit of 20,000 files per deployment, with error 10304. The author specifically notes that this limit applies to the number of assets in a single deployment version and is unrelated to the number of deployments per month.
Midway inventory numbers were: local directory about 4.9 GB, .git about 2.7 GB, local image backup about 1.7 GB, currently tracked files about 223 MB. These measurements can’t be conflated—fewer current files doesn’t mean a full clone will immediately shrink.
The most counterintuitive lesson came after untracking: on the migration branch, rm --cached removed the images, and the local files were indeed still there; but when switching back to old main and then merging that migration commit containing deletion records, Git deleted the 9,263 sample images in the working tree; they were finally restored from the old commit and the count rechecked. rm --cached only touches the index; it does not mean subsequent merges will preserve the files; on devices that already have a complete image library, move the backup outside the repo before pulling this kind of deletion commit.
Moving images isn’t just changing addresses: indexes, publish order, and concurrency

Build logic such as deduplication and color recommendations originally read local images, so merely uploading and replacing homepage URLs was far from done. The author first inventoried all references, confirmed that all 9,263 sample images had sources and no orphan files, kept the original path structure images/thumbs/<styleSlug>/<md5>.webp, and generated scripts/image-manifest.json recording object path, MD5, byte count, dimensions, format, upload receipt, plus dHash and color vector. This index lets build scripts read metadata directly without downloading the entire image library. MD5 here is used for content addressing and consistency checks, not for security authentication.
The publish order was explicitly fixed: if pages go live first while images are still uploading, users see missing images, so the single entry point chains “validate—upload—check references—build” into one sequence. The upload side reuses connections per thread, adds exponential backoff on timeout retries, and saves the index every 100 objects processed; during resume testing, 64 concurrent requests were tried, and the final default was set to 8—higher concurrency doesn’t necessarily increase effective throughput and may instead increase timeouts and retries. The author also explicitly says no strict controlled experiment was done, so this number should not be taken as a general recommendation.
Validation had two layers: a remote check covered all 9,263 images, verifying response status, Content-Length, ETag, and CORS; another sample of about 30 images was actually downloaded and MD5-checked; the first sample check hit network timeouts and passed after GET retries were added.
The storage division of labor changed, along with two easy-to-miss changes

| Part | At launch | After upgrade |
|---|---|---|
| Pages and prompt data | Saved and published in Git | Kept on the original flow |
| Sample image files | Entered Git and deployments along with code | Stored in R2; browsers request the image domain directly |
| Image build information | Computed by reading local images | Metadata index is committed; historical images don’t require downloading the whole library |
| Admin historical stats | Extracted from Git history | Uses a separate compressed archive, appending snapshots as content changes |
| Local preview | Depended on local sample images, falling back to remote when missing | Uniformly reads sample images from R2 |
A cross-origin <a download> cannot guarantee download under the specified filename, so desktop downloads were changed to fetch the image, generate a Blob and temporary object URL, and then trigger the download; after images moved to the R2 domain, they no longer pass through the original Worker’s UA blacklist. The author configured independent WAF rules for the image domain and disabled the public r2.dev entry point, while noting that UA can be spoofed—this is only rule validation, not complete hotlink protection.
This approach fits projects like these: binary assets such as images keep growing, builds depend on the entire repository’s files, and business history is bound to Git. If the asset volume is still small, or the team must preserve complete commit history, you can begin with a shallow clone or a git-filter-repo filtering approach—the author himself treated “history reset” and “image migration” as two independent decisions, ultimately choosing to create a new root commit and bring local .git down to about 68 MB, at the cost of making old commits unreachable.
One more thing worth noting: a lighter repo does not mean faster pages. No before/after performance benchmark was done this time; load speed still depends on image size, caching, and network; R2 storage volume, operations, and costs also need long-term observation—you can’t infer permanent zero cost from a single validation.
Final thoughts
What’s worth remembering isn’t the efficiency figure of “half a day,” but how a single deployment failure pushed the early shortcut of keeping images and code in the same repo to its limit. Splitting code, images, and stats into three kinds of storage, then designing a fixed order around the fact that there are no transactions between them, was the real cost of this upgrade. The author’s answer is to leave verifiable results at every step, then check whether the old problem has actually disappeared.