HomeTutorialsOpenClaw GitHub
    — AI Agents

    Connect OpenClaw to GitHub

    Learn how to give your OpenClaw AI agent full access to push, commit, and manage your GitHub repositories — explained in plain English, from scratch.

    Beginner Friendly~15 MinutesUbuntu VPSNo experience needed

    Table of Contents

    1. 01.What You'll Need
    2. 02.Step 1: Create a GitHub Personal Access Token
    3. 03.Step 2: Create a GitHub Repository
    4. 04.Step 3: Add Your Token to Your VPS
    5. 05.Step 4: Give OpenClaw Your Repository Details
    6. 06.Step 5: Fix Git Authentication (If a Push Fails)
    7. 07.Step 6: Verify Everything Is Working
    8. 08.Troubleshooting
    9. 09.Summary
    BEFORE YOU BEGIN

    What You'll Need

    • A GitHub account — free at github.com
    • A VPS (Virtual Private Server) with OpenClaw already installed and running
    • Access to your VPS terminal via SSH (the black command-line window)
    • About 15 minutes of focused time
    STEP 1

    Create a GitHub Personal Access Token

    GitHub no longer allows you to use your account password to push code from scripts or bots. Instead, it uses a Personal Access Token (PAT) — think of it like a special password created just for your OpenClaw bot. You generate it once, give it to OpenClaw, and it handles everything from there.

    💡 Quick Shortcut

    Go directly to github.com/settings/tokens while logged in to skip to the token page instantly.

    1. Log into github.com and click your profile picture in the top-right corner
    2. Click Settings from the dropdown menu

    ⚠️ Common Mistake

    You want your account Settings — not the Settings tab inside a repository. Always click your avatar first.

    1. Scroll all the way to the bottom of the left sidebar and click Developer settings
    2. Click Personal access tokensTokens (classic)
    3. Click Generate new tokenGenerate new token (classic)
    4. Fill in the form:
    Field
    What to Enter
    Note
    OpenClaw VPS — just a label so you remember what this token is for
    Expiration
    90 days is a safe default. You can always regenerate it later.
    Scopes
    Check repo only — this is all OpenClaw needs
    1. Scroll down and click Generate token
    2. Copy your token immediately — GitHub shows it only once. Paste it into a text file or notes app for now.

    ⚠️ Don't Close That Page Yet!

    Once you navigate away from GitHub, the token disappears forever. If you lose it, you'll need to generate a new one.

    STEP 2

    Create a GitHub Repository

    A repository (or "repo") is like a folder on GitHub where your files live. OpenClaw needs a repo to push its files into. If you already have one set up, skip ahead to Step 3.

    1. Go to github.com/new
    2. Give your repo a clear name — for example: openclaw-workspace
    3. Choose Public or Private — either works fine
    4. Click Create repository
    5. Copy your repository URL — it will look like this:
    https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git

    📋 Save This URL

    You'll need to provide this URL to OpenClaw when it asks where to push files. Copy it now.

    STEP 3

    Add Your Token to Your VPS

    Now SSH into your VPS and run the command below. This stores your token as an environment variable — which is like leaving a sticky note in your terminal's memory. Any app running in the same session, including OpenClaw, can read it without you having to type it every time.

    Replace your_token_here with the token you copied from GitHub:

    export GITHUB_TOKEN=your_token_here

    The export command only lasts as long as your terminal session is open. If you reboot your server or close your SSH window, it disappears. To make it permanent, run these two commands instead:

    echo 'export GITHUB_TOKEN=your_token_here' >> ~/.bashrc
    source ~/.bashrc

    What Does This Actually Do?

    echo '...' >> ~/.bashrcAdds the export command to your shell's startup file, so it runs automatically every time you log in
    source ~/.bashrcReloads the startup file immediately so the change takes effect right now without restarting

    💡 Using Zsh?

    If your VPS uses Zsh instead of Bash, replace ~/.bashrc with ~/.zshrc in the commands above.

    STEP 4

    Give OpenClaw Your Repository Details

    When OpenClaw asks where to push your files, provide these three pieces of information:

    Setting
    Value
    Why
    Repository URL
    https://github.com/USERNAME/REPO.git
    Points OpenClaw to the right GitHub repository
    Branch
    main
    The default branch GitHub creates for new repos
    Path
    / (root)
    Files go into the top-level folder of the repo

    🔗 Always Use the HTTPS URL

    Make sure your repo URL starts with https://github.com/ — not git@github.com:. The SSH format won't work with token authentication.

    STEP 5

    Fix Git Authentication (If a Push Fails)

    Sometimes you'll see this error even after setting your token:

    fatal: could not read Username for 'https://github.com'

    This happens because your token is stored in your shell environment, but git runs in its own separate process and can't see it. The fix is simple — you write the token into a dedicated git credentials file that git knows how to read.

    Run these three commands in your terminal:

    git config --global credential.helper store
    printf "https://x-access-token:%s@github.com\n" "$GITHUB_TOKEN" > ~/.git-credentials
    chmod 600 ~/.git-credentials

    Line-by-Line Breakdown

    git config --global credential.helper storeTells git: "look for credentials in a local file, not a password prompt"
    printf "..." > ~/.git-credentialsWrites your token into that credentials file in the exact format GitHub expects
    chmod 600 ~/.git-credentialsLocks the file so only your user account can read it — keeps your token secure

    After running these commands, git will silently use your token for all future GitHub operations. No more prompts, no more errors.

    STEP 6

    Verify Everything Is Working

    Run this command to confirm that git can now authenticate with GitHub. Replace the placeholders with your actual username and repo name:

    git ls-remote https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git

    If it works: You'll see a list of branch names and commit hashes — that means GitHub accepted your credentials and OpenClaw is ready to go.

    If it fails: Double-check that your token was copied correctly and that you selected the repo scope when creating it. Then jump to the Troubleshooting section below.

    TROUBLESHOOTING

    Common Problems & Fixes

    Authentication is still failing even after setting the token

    Run echo $GITHUB_TOKEN — if it prints nothing, the variable wasn't saved. Make sure you ran source ~/.bashrc after adding it. Also check that the token hasn't expired on GitHub under Settings → Developer settings → Tokens.

    My token expired — what do I do?

    Go to github.com/settings/tokens, click your old token, and click Regenerate token. Then repeat Steps 3 and 5 with the new token value. The old one stops working as soon as it expires.

    My push is being rejected even though auth works

    Check that your branch name matches exactly — GitHub creates main by default, but older repos may use master. Also make sure your token has the full repo scope, not just public_repo.

    I'm getting "Repository not found" errors

    Make sure you're using the HTTPS URL format: https://github.com/username/repo.git — not the SSH format that starts with git@github.com:. Token authentication only works over HTTPS.

    🎉 You're All Set — Here's What You Did

    1Created a GitHub Personal Access Token with repo scope
    2Created a GitHub repository for OpenClaw to write to
    3Stored the token as an environment variable on your VPS
    4Provided OpenClaw with your repo URL, branch, and path
    5Wrote the token to ~/.git-credentials so git can use it
    6Verified authentication with a live test command

    OpenClaw can now clone, commit, and push to your GitHub repository automatically — no manual input required on every run.