Skip to content
refs

fix(cli): give a session token only to git that its agent runs

Aman Kumarcommitted Dec 3, 2026bdcbbb2parent fb1aa72

Before, the credential helper kept one session token for each remote and gave it to every git process on the machine. When an agent took a branch, a person who pushed the default branch from any terminal pushed as the agent, and refs refused the push. Now the helper keeps one token for each agent process. It gives a token only to git that runs under that agent. Everyone else gets the person's own sign-in. Tokens of agents that stopped are dropped. decision: When git does not run under the agent that holds a token, the helper gives it the person's own sign-in. The agent's session token is no longer the default for the whole machine. reason: - A person must be able to push the default branch while an agent works in the same clone. - The person's sign-in was already the answer when no agent held a token. assumptions: - An agent client runs git as a child of the process that started the refs MCP server. Claude Code does this. - OpenCode runs one shared server, so its sessions on one repository share one token, as before. to_reverse: Go back to one token for each remote. People then lose pushes of the default branch while an agent works. rejected: Environment: an environment variable for the token does not reach the shell of Claude Code or OpenCode. affected_components: - apps/cli/refs.mjs evidence: - apps/cli/test/credential.test.ts

4 files changed · +63 −9
apps/cli/refs.mjs+42 −6
apps/cli/test/credential.test.ts+18 −0
apps/frontend/docs/cli.md+2 −2
apps/frontend/docs/protocol.md+1 −1