Forge Authentication
GitHub and GitLab CLI setup for branch publishing and review-request publishing.
Agentty uses plain Git for branch publishing and then uses the forge CLI for pull-request or merge-request actions.
p pushes the branch before creating a review request. Authenticate both Git and the forge CLI: HTTPS remotes need Git credentials; SSH remotes need an SSH key.
For the session-view publish flow, see Workflow.
GitHub🔗
Use this setup when the repository remote is on GitHub.
- Run
gh auth login. - Choose the target host such as
github.com. - Pick the Git protocol Agentty should use for branch publishing:
httpsorssh. - If you picked
https, rungh auth setup-gitafter login so Git can useghas a credential helper for branch pushes. - Verify the setup with
gh auth status.
Review watch's automatic check rerun needs a token with Actions write access. Without it, review watch still sees failing checks and reports that it could not rerun them.
Merging a pull request with m runs gh pr merge, so the account needs permission to merge into the base branch; a bypass merge also needs the right to bypass its branch protections.
Linking the pull requests of nodes built on one another into a GitHub stack needs the optional gh-stack extension: gh extension install github/gh-stack. Without it, they keep the bases Agentty set by hand.
GitLab🔗
Use this setup when the repository remote is on GitLab.
- Run
glab auth login. - Choose the target host such as
gitlab.comor your self-hosted hostname. - Pick the Git protocol Agentty should use for branch publishing:
httpsorssh. - Verify the CLI login with
glab auth status --hostname <hostname>. - If you picked
https, also configure Git itself for HTTPS pushes: either a credential helper or a personal access token that Git can use whengit pushprompts for credentials.
If glab auth status says you are authenticated but Agentty still reports a push-authentication failure, the missing piece is Git HTTPS credentials rather than glab authentication.
Repository Settings Agentty Ignores🔗
Agentty pushes and reads the remote without the repository's own Git configuration: only your global and system configuration apply. A credential helper, core.askPass program, proxy, or core.sshCommand set in the repository's .git/config does not apply to Agentty's pushes. Agents can write that file, and Agentty pushes outside their sandbox, so such a setting would let an agent run a program as you.
Two settings still give one repository its own credentials:
An HTTPS credential helper scoped to the repository's URL, in your global configuration:
git config --global credential.https://github.com/owner/repo.git.helper <helper>.An SSH key for one repository, through a host alias in
~/.ssh/config, used as the remote's address:Host github-work HostName github.com IdentityFile ~/.ssh/id_workwith the remote set to
git@github-work:owner/repo.git.
Other repository-level settings, such as http.extraHeader, http.sslCAInfo, and global settings keyed on the repository's folder (includeIf "gitdir:..." or onbranch:), do not apply either; set them globally for the remote's address instead.
A token written into the remote's URL keeps working, and Agentty removes it from the messages it writes, but Git itself shows the URL to the programs it starts, so a credential helper is the safer place for it.
A session's pushes, its node branches, the check for its remote branch, the fetch of its base before a session sync, the fetch of a review's branches, and the repository the forge CLIs act on reach origin only at the addresses Agentty recorded when it made the session's worktree, before any agent worked in it. Changing origin's address or push address later does not move them, and node branches wait while the session's origin names another address. A local path inside the project or among the sessions' worktrees, where other sessions' agents write, is not recorded, and neither is an origin Git could not read when the session started. Agentty records the addresses only then, never from a later read or push, and never takes them from the repository's configuration afterwards, because an agent can write it. When nothing is recorded, the session says that publishing is unavailable and why, and every push, review request, and node branch refuses with that reason. A session that started before Agentty recorded addresses refuses the same way, unless the project has a confirmed remote to offer it. A branch published to a remote other than origin is not pushed again.
Recording is not consent: nothing is pushed to, or fetched from, the recorded addresses until you confirm them. When a session whose remote is not confirmed publishes, syncs on a fetched base, or merges its review request, Agentty asks, in a prompt that shows every fetch and push address in full. Credentials are removed, and a control or invisible character is written out as \u{..}. The prompt also warns when an address is a local path or loopback address, since a push there runs that repository's hooks. When the terminal is too small to show everything, the prompt asks for a larger one and only cancels. y confirms the addresses for the session and makes them the project's confirmed remote, which also confirms the project's other sessions that record the same addresses and gives them to those with other addresses that have published nothing; n or Esc cancels, and the prompt starts on cancel. Once the project's remote is confirmed, a session that records the same addresses needs no question, and the confirmation survives a restart. Sessions that exist when Agentty first asks start unconfirmed, and nothing is backfilled from your current configuration.
When a session records other addresses than the project's confirmed remote, as when an agent rewrote origin before the session started, the prompt shows both. y confirms the session's addresses for the project, and k keeps the project's remote instead, which gives it to a session that has not published yet; a session that already published keeps its own addresses and offers only y and n. A session's choice holds only while the project's confirmed remote is still the one the prompt showed, so a prompt left open while you confirmed another remote, in a second terminal for example, replaces nothing: it opens again with the current addresses and says that the remote changed. A session from before Agentty recorded addresses has none to show, so the prompt offers the project's remote, when it has one. A session that recorded no address for a reason still refuses with that reason.
Only the terminal asks. agentty run and a paired device never prompt: a request to publish or merge from either is refused with a message that names the confirmation, until you confirm in the terminal, and node branches wait for it, with the session open in the terminal to publish or sync it.
Every address must be HTTPS, SSH, or an absolute local path. A push goes to each push address in turn and stops at the first that fails, naming it and the addresses that already took it. The remote-tracking branch moves to the pushed commit only from the commit it held before the push, so a fetch that moved it meanwhile keeps its commit.
Syncing your project's checked-out branch and the background fetch reach only the project's confirmed remote, the one the prompt above makes, and use its addresses whatever origin names now: the sync pulls the branch of the same name from the confirmed fetch address and pushes to the branch of the same name at each confirmed push address. A pushRemote or remote.pushDefault does not apply. A branch tracking a branch of another name on origin is neither pulled nor pushed, and one tracking another remote keeps its upstream. origin is read only to compare it with the confirmed remote. Agents in the sessions' worktrees share the project's configuration and can change origin's address, so when the project has no confirmed remote or origin names other addresses, the background fetch does nothing and the status bar says once that origin is not confirmed. s then asks the question above for the project, showing both when the project has a confirmed remote: y confirms origin's addresses for the project, k keeps the confirmed remote and syncs with it, and n or Esc cancels. An origin that names a repository inside the project or Agentty's session folders, where agents write, is refused instead of asked about, and so is a project with no origin and no confirmed remote. agentty run and a paired device never prompt: a sync they start is refused with a message that names the confirmation.
gh and glab run in a new empty directory outside the session's worktree, never in it, and name the repository and its host on their command line instead. The directory is made under ~/.agentty/tmp/forge (or $AGENTTY_ROOT/tmp/forge), a folder only you can open, and never under the system temporary directory, which agent sandboxes can write: an agent that could write the folder could swap a directory for a link into its worktree before the command starts. Agentty creates the folder readable by you alone and refuses to run the forge CLIs while it is a link or open to other users. This holds while no agent can write inside the Agentty root, which the sandboxes of Agentty's agents do not allow; running an agent without a sandbox, or granting it that folder, removes the protection. Both programs start git for some commands, and git reads the repository around its working directory, where an agent can write core.sshCommand, credential.helper, url.<base>.insteadOf, include.path, and hooks. Their environment points GIT_DIR at a repository that does not exist, drops GIT_WORK_TREE and the other variables that point git at a repository, stops git from climbing out of that directory into one, and turns off the system-wide Git configuration with GIT_CONFIG_NOSYSTEM. Your own gh or glab login and your global Git configuration apply, except for includeIf conditions on the repository's path, which the empty directory never matches. A setting that only a repository's own configuration held, such as a credential.helper in .git/config, does not reach them: put it in your global configuration, as above.
Every call goes to the host of the repository's recorded remote, whatever your environment holds: a GH_HOST or GITLAB_HOST exported in your shell does not redirect Agentty's calls. gh gets the host in GH_HOST, in the repository it is given (github.com/owner/repo), and in --hostname; glab gets it in GITLAB_HOST and the repository's address. Sign in to that host with gh auth login or glab auth login, as above.