Get to GitHub·Beginner

How to Export Replit Code to GitHub

Connect a Replit project to GitHub from the Git pane, turn on two-way sync, keep your secrets out of the repo, then check the code before you launch.

Use this guide if you built an app on Replit, with Agent or by hand, and want a copy of the code on GitHub: as a backup, to work on it in a local editor, or to deploy it elsewhere. Replit's Git pane handles it without the command line.

Before you start

  • A GitHub account. It's free at github.com.
  • Your Replit project open in the editor.

Export your Replit project to GitHub

Link your GitHub account from your Replit account's connected services. You only need to do this once.

Step 2: Open the Git pane

In your project, go to the Tools section, select the + sign to add a tool, and choose Git.

Step 3: Set up the repository if needed

If the project isn't a Git repository yet, the Git pane offers to initialize one. Do that first.

Step 4: Connect the project to GitHub

From the Git pane, connect the project to GitHub and choose the repository it should sync with.

Step 5: Commit and push

Review your changes in the Review Changes section, stage the files, write a commit message (Replit AI can draft one for you) and commit. Then push to send your commits to GitHub.

Step 6: Turn on auto-sync

To keep Replit and GitHub in step in both directions, turn on auto-sync in the Git pane.

Step 7: Check the repo on GitHub

Open the repository on GitHub and confirm your files are there.

If Git sync stops working later, Replit's advice is to reconnect GitHub from your connected services. They note that a fine-grained personal access token gives a more reliable connection.

Prefer the Shell?

Replit's Shell has standard Git and the GitHub CLI (gh), and anything you do there shows up in the Git pane too. Create an empty repository on GitHub first, without a README, license or .gitignore (GitHub's docs say this avoids errors). If the project isn't a Git repository yet, run git init first. Then run:

git add .
git commit -m "Prepare for GitHub"
git remote add origin https://github.com/your-name/your-repo.git
git push origin main

The first two lines commit anything you haven't committed yet. If Git says there's nothing to commit, that's fine: carry on with the next two.

If your branch isn't called main, use its name instead. GitHub asks you to sign in when you push. Use a personal access token, not your password. Replit's docs describe saving the token inside a GIT_URL secret so you don't retype it, but they also warn that anyone with access to your project can then potentially reach your Git credentials. For anything sensitive, typing the token when asked is the safer habit.

Only need a one-off copy? Select the three-dot menu at the top of the file tree and choose Download as zip.

What changes after you export

Two-way sync once auto-sync is on. With auto-sync turned on, the Git pane keeps Replit and GitHub in step in both directions. You can still push and pull by hand from the Git pane or the Shell at any time.

Agent checkpoints are Git commits. Replit stores Agent checkpoints in Git, so they appear in the Git pane next to your own commits and can sync to GitHub like any other commit.

Secrets stay in Replit. Secrets you add in the Secrets tool are encrypted and handed to your app as environment variables, which is how Replit keeps them out of your code. Your published app uses a separate set: secrets in the development Secrets pane are only available in the editor, and the ones your live app uses are under Publishing → Adjust settings → Production app secrets. If you added Replit's database, its connection string is stored as the DATABASE_URL secret.

Hard-coded keys travel with the code. Replit's own docs list checking code into a public repository as one of the ways hard-coded secrets get exposed. Anything typed straight into a file goes to GitHub with everything else, which is why the first check below matters.

Before you ship: what to check in the exported repo

Replit apps come in every stack, so these checks stick to what applies almost everywhere. Work through them before you share the link:

  1. No keys typed into source files. Search the repository for API keys, tokens and connection strings written into the code. They belong in the Secrets tool. If a real key made it into a commit, rotate it first, because removing the file doesn't remove it from Git history. More on why: secret exposure.
  2. No secret keys reach the browser. Variables prefixed with VITE_ or NEXT_PUBLIC_ are bundled into the code sent to the browser. Stripe secret keys, AI provider keys and database credentials should only be read on the server. See Secret API key exposed in client bundle.
  3. Every route checks who's asking. An endpoint that returns a record by id should confirm the signed-in user owns it, or anyone can change the id and read someone else's data. See IDOR on a REST endpoint and Auth check only in client code.
  4. Writes validate their input. Routes that save data should check fields, types and ranges before touching the database. See Missing input validation.
  5. Sign-in and AI endpoints are rate limited. Without limits, one script can hammer your login or run up your AI bill. See No rate limiting on sensitive endpoints.
  6. Errors fail gently. A failed request should show a clear message, not a blank screen. See Error handling in AI-built apps.

For a Replit-specific rundown, see Replit to production: what to check first.

Before launch: a review of the whole repo

For the full picture, install the FinishKit GitHub App and pick the repositories it can see. It works with private and public repositories and reviews your code across eight production readiness dimensions before handing you a Finish Plan with the blockers on top. If the repo is public and you want something quicker first, the free quick readiness check runs a short set of checks from just the URL.

Sources: Replit: Using the Git pane, Replit: Projects and files, Replit: Version control, Replit: Secrets, GitHub Docs: Adding locally hosted code to GitHub, GitHub Docs: Removing sensitive data from a repository, GitHub Docs: Managing your personal access tokens, Vite: Env variables and modes, Next.js: Environment variables.