# Give a workstation access to GitHub

> For the complete documentation index, see [llms.txt](https://docs.ringleader.dev/llms.txt).


> Clone and push a private GitHub repository from a workstation with git, using a personal access token that no program on the workstation can read.


Clone and push a private GitHub repository from a workstation with `git`, using a personal
access token that no program on the workstation can read. Ringleader adds the token to
requests for GitHub as they leave the workstation, so the workstation never holds it. Use
this when you want your code, or your coding agent's work, in a repository you own.

## Prerequisites

- [Ringleader installed](https://docs.ringleader.dev/install/), with the Ringleader application
  running.
- A running workstation on your computer, labeled `role: agent`. The examples use a
  workstation named `my-git-box`; replace it with yours. To create one, follow the
  [Quickstart](https://docs.ringleader.dev/quickstart/) and use your own name. Then run
  `rl workstation label my-git-box role=agent -n local`. A cloud workstation needs an Edge,
  as [Providers and where the key is added](https://docs.ringleader.dev/security/credentials/injected-credentials/#providers-and-where-the-key-is-added)
  describes, so this guide is for a workstation on your computer.
- A GitHub personal access token that can read and write the repository.

## Add your token and Git identity

Store the token in a Secret, then apply one file. The file adds the token to every
workstation with the label. It also installs `git` and sets the name and email on your
commits.

1. Store the token in a Secret named `github-pat`:

   ```bash
   rl secret create github-pat -n local --from-string token=<your-token>
   ```

2. Save this as `my-git.yaml`, with your own name and email. The Integration holds the
   token. The WorkstationConfig installs `git` and writes your identity:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: my-github
     namespace: local
   spec:
     type: httpProxy
     selector:
       matchLabels:
         role: agent
     httpProxy:
       vendor: github
       credentialRef:
         name: github-pat
         key: token
   ---
   apiVersion: workstations.ringleader.dev/v1
   kind: WorkstationConfig
   metadata:
     name: my-git-identity
     namespace: local
   spec:
     selector:
       matchLabels:
         role: agent
     devtools:
       - name: git
     toolconfigs:
       - id: git
         name: git
         config:
           userName: Your Name
           userEmail: you@example.com
   ```

   <div class="callout callout-warning">
  <p class="callout-title">The workstation can use your token</p>
  <div class="callout-body">
    Every program in the workstation, your coding agent included, can use GitHub with the
access your token has, though none can read the token. Create a token that reaches only
the repositories you need, and keep the Integration behind a label, as this file does.
  </div>
</div>


3. Apply the file. It reaches the workstations that carry the label now and the ones you
   create later:

   ```bash
   rl apply -f my-git.yaml
   ```

4. Wait until the workstation has applied it:

   ```bash
   rl workstation wait my-git-box --for Configured --timeout 10m -n local
   ```

   The command returns once the workstation's `Configured` condition is `True`.

## Clone and push a private repository

Clone the repository, commit a change and push it from the workstation's shell over HTTPS, with no password prompt.

1. Open a shell on the workstation:

   ```bash
   rl shell my-git-box -n local
   ```

2. Clone your repository. The clone finishes without asking for a password:

   ```bash
   git clone https://github.com/your-org/your-app.git
   ```

3. Change into the repository's folder:

   ```bash
   cd your-app
   ```

4. Create a file to commit, since a fresh clone has no changes:

   ```bash
   echo "test" >> push-test.txt
   ```

5. Stage the file:

   ```bash
   git add push-test.txt
   ```

6. Commit the file. The commit carries your name and email:

   ```bash
   git commit -m "Try a push from my workstation"
   ```

7. Push the commit. The push finishes without asking for a password:

   ```bash
   git push
   ```

## Troubleshoot

- If the clone fails with an authentication error, check that the Integration reached the
  workstation. Run `rl workstation get-resolved-configuration my-git-box -n local` and
  look for `integration-my-github` under `appliedConfigs`. If it's missing, the workstation
  doesn't carry the label `role: agent`.

## Next steps

- [Injected credentials](https://docs.ringleader.dev/security/credentials/injected-credentials/) explains how
  Ringleader adds the token outside the workstation, and where it works.
- [Connect your GitHub account](https://docs.ringleader.dev/guides/connect-github-app/#connect-your-github-account)
  gets a short-lived token for you, so you don't create or rotate a token.
- [Use several GitHub identities on one workstation](https://docs.ringleader.dev/guides/use-several-github-identities/)
  adds a second token, such as a bot account's, and chooses which one each request uses.
- [SSH keys for outbound Git](https://docs.ringleader.dev/workstations/connectivity/git-ssh-keys/)
  clones over SSH with a key from your computer, and says what that costs.
- [Create a front-end workstation](https://docs.ringleader.dev/guides/create-front-end-workstation/) builds a workstation
  for front-end work, with your own project on it.

