Skip to content

fix: restore correct remote URL in git snapshots#159

Merged
nssherpa merged 1 commit intomainfrom
nsherpa/fix-snapshot-git-config
Feb 25, 2026
Merged

fix: restore correct remote URL in git snapshots#159
nssherpa merged 1 commit intomainfrom
nsherpa/fix-snapshot-git-config

Conversation

@nssherpa
Copy link
Contributor

@nssherpa nssherpa commented Feb 25, 2026

When generating a snapshot, git clone <local-mirror-path> causes Git to write the local mirror path as remote.origin.url in the snapshot's .git/config. After clients extract the snapshot and run git pull, Git tries to reach the local path (e.g. /app/state/git-mirrors/github.com/squareup/java) which doesn't exist on their machine.

Fix: after the local clone, run git remote set-url origin <upstream> to restore the correct upstream URL before archiving the snapshot.

Testing

  1. Start cachew
just docker build && docker run --rm -it \
  -p 8080:8080 \
  -v ~/.scripts/github/blox-cache.2026-02-03.private-key.pem:/app/github-app-key.pem:ro \
  -e CACHEW_GITHUB_APP_APP_ID="2666596" \
  -e CACHEW_GITHUB_APP_PRIVATE_KEY_PATH="/app/github-app-key.pem" \
  cachew:local
  1. Clone a repo
time git clone --depth 1000 http://localhost:8080/git/github.com/block/cachew.git ~/Development/gitclones/cachew-clone
  1. Fetch snapshot
time sh -c 'mkdir ~/Development/gitclones/cachew-stream &&  curl http://localhost:8080/git/github.com/block/cachew.git/snapshot.tar.zst | zstd -dc | tar -xpf - -C ~/Development/gitclones/cachew-stream'
  1. cd into the tar-d repo and run git pull, check git config, etc. The url is now correct.
cd ~/Development/gitclones/cachew-stream
Hermit environment /Users/nsherpa/Development/gitclones/cachew-clone deactivated
Hermit environment /Users/nsherpa/Development/gitclones/cachew-stream activated
❯ git pull --rebase
Already up to date.
❯ cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = http://127.0.0.1:8080/git/github.com/block/cachew
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main

previously it would be something like this

🐚 bloxer@workstation-25886-7f94ff4c9c-4jkw8:~/java-stream$ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = /app/state/git-mirrors/github.com/squareup/java
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

@nssherpa nssherpa force-pushed the nsherpa/fix-snapshot-git-config branch 2 times, most recently from 01e87f8 to d475f95 Compare February 25, 2026 19:00
@nssherpa nssherpa marked this pull request as ready for review February 25, 2026 19:00
@nssherpa nssherpa requested a review from a team as a code owner February 25, 2026 19:00
@nssherpa nssherpa requested review from wsutina and removed request for a team February 25, 2026 19:00
@nssherpa nssherpa force-pushed the nsherpa/fix-snapshot-git-config branch 5 times, most recently from dd65913 to a0ee78f Compare February 25, 2026 20:23
When generating a snapshot, `git clone <local-mirror-path>` sets
`remote.origin.url` to the local mirror path. After cloning, reset the
origin URL to the actual upstream so clients can run `git pull` after
extracting the snapshot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nssherpa nssherpa force-pushed the nsherpa/fix-snapshot-git-config branch from a0ee78f to e0210d6 Compare February 25, 2026 20:28
@nssherpa nssherpa merged commit bf5c4dd into main Feb 25, 2026
6 checks passed
@nssherpa nssherpa deleted the nsherpa/fix-snapshot-git-config branch February 25, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant