Title: Git auto-init: optional `X-Git-Remote` header to configure origin on the new repo · Issue #476 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: Git auto-init: optional `X-Git-Remote` header to configure origin on the new repo · Issue #476 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: Git auto-init: optional `X-Git-Remote` header to configure origin on the new repo · Issue #476 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Context When JSS auto-inits a repo on first git-receive-pack push (#466/#469), the resulting .git/config has no remotes configured. That's correct for the create-on-push semantics — JSS doesn't know where the client cloned from. In pract...
Open Graph Description: Context When JSS auto-inits a repo on first git-receive-pack push (#466/#469), the resulting .git/config has no remotes configured. That's correct for the create-on-push semantics — JSS doesn't kno...
X Description: Context When JSS auto-inits a repo on first git-receive-pack push (#466/#469), the resulting .git/config has no remotes configured. That's correct for the create-on-push semantics — JSS doesn...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/476
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Git auto-init: optional `X-Git-Remote` header to configure origin on the new repo","articleBody":"## Context\n\nWhen JSS auto-inits a repo on first `git-receive-pack` push (#466/#469), the resulting `.git/config` has no remotes configured. That's correct for the create-on-push semantics — JSS doesn't know where the client cloned from.\n\nIn practice this bites pod operators who later `cd` into the pod-side install dir and want to track upstream:\n\n```bash\n$ cd pod-data/public/apps/chrome\n$ git pull\nfatal: no upstream branch configured\n$ git pull origin\nfatal: 'origin' does not appear to be a git repository\n```\n\nThe user has to manually `git remote add origin \u003cupstream>` and `git branch --set-upstream-to` for every installed app.\n\n## Proposal\n\nWhen a push triggers auto-init, optionally read an `X-Git-Remote` HTTP header from the client. If present, validated, and not already configured on the (just-auto-init'd) repo, run the equivalent of:\n\n```bash\ngit -C \u003crepoAbs> remote add origin \u003cvalue>\ngit -C \u003crepoAbs> branch --set-upstream-to=origin/main main # if HEAD is main\n```\n\nso the operator can `git pull` later without ceremony.\n\n## Surface\n\n```\nPOST /public/apps/foo/git-receive-pack HTTP/1.1\nAuthorization: Bearer \u003ctoken>\nContent-Type: application/x-git-receive-pack-request\nX-Git-Remote: https://github.com/solid-apps/foo\n...\n```\n\n## Constraints\n\n- **Only on auto-init path.** Don't touch `.git/config` of a pre-existing repo — that's the operator's territory, surprise-edits there are unacceptable.\n- **Validate the value.** URL must match `^https?://[A-Za-z0-9._/:-]+$`. Reject `git@`, `ssh://`, `file://`, anything with shell metacharacters, anything with `..`. This is the same sort of guard `tryAutoInitRepo` already needs against symlink shenanigans (called out in its docstring).\n- **No-op if not present.** Header is purely opt-in; existing clients keep working.\n- **Run after `git init`, before the push proceeds.** Otherwise the push could race with the config write.\n- **Use `git remote add` and `git branch --set-upstream-to` via `spawnSync`** — don't hand-roll the config file. `git` writes the right shape.\n\n## Scope\n\n~25 LoC + a test in `test/git-auto-init.test.js`:\n\n```js\nit('configures origin from X-Git-Remote when present on first push', async () => {\n const url = `${baseUrl}/public/apps/penny/info/refs?service=git-receive-pack`;\n const res = await fetch(url, {\n headers: { 'X-Git-Remote': 'https://github.com/solid-apps/penny' }\n });\n assert.strictEqual(res.status, 200);\n const configPath = path.resolve(DATA_DIR, 'public/apps/penny/.git/config');\n const cfg = readFileSync(configPath, 'utf8');\n assert.ok(cfg.includes('[remote \"origin\"]'), 'origin should be configured');\n assert.ok(cfg.includes('url = https://github.com/solid-apps/penny'));\n});\n```\n\nPlus a negative test: malformed URL → header silently ignored, push still succeeds.\n\n## Why this is JSS-level (not jspod-level)\n\n- Only JSS knows when auto-init fires (the trigger that \"the repo is new and we can safely write config\")\n- Works for any client (jspod install, raw `git push`, future tools), not just the wrapper\n- Operators who deploy JSS directly benefit too\n\n## Cross-references\n\n- Client side: jspod will add the header in `jspod install` once this lands. Tracked separately as a jspod follow-up.\n- #471 (auto-init default branch) — same surface area; this proposal also benefits from the deterministic `main` default for the `branch --set-upstream-to` step.","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2026-05-17T12:39:38Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/476"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2f16de6b-6bef-c33f-2651-a3ea477cabe4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8EAA:1F98:6C0D7:8BA94:6B03A2B6 |
| html-safe-nonce | 83a50e0e37baa3ce8e9eabdcbba73a3f8b29412b2d4aed0bb831328e95910c6d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUFBOjFGOTg6NkMwRDc6OEJBOTQ6NkIwM0EyQjYiLCJ2aXNpdG9yX2lkIjoiNzA2NjEyNTE2OTc3NzE1Njc5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f680974d3c3dd1f57e6e2591a90e81ba8fec4a4a50d4ce7d1d1755d2845ca9b9 |
| hovercard-subject-tag | issue:4463493659 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/476/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9735716e79bf87c9beb7a323795f17689676b656acb7ce3c7cb84f8a72cde9ef/JavaScriptSolidServer/JavaScriptSolidServer/issues/476 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9735716e79bf87c9beb7a323795f17689676b656acb7ce3c7cb84f8a72cde9ef/JavaScriptSolidServer/JavaScriptSolidServer/issues/476 |
| og:image:alt | Context When JSS auto-inits a repo on first git-receive-pack push (#466/#469), the resulting .git/config has no remotes configured. That's correct for the create-on-push semantics — JSS doesn't kno... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width