Import a GitHub repository into Replit using the rapid import method (paste replit.com/github.com/user/repo in your browser) or the guided import at replit.com/import. For private repos, connect your GitHub account through OAuth or store a Personal Access Token in Replit's Secrets panel. Once imported, two-way Git sync keeps your Repl and GitHub repository in sync automatically.
Import Any GitHub Repository Into Replit in Minutes
This tutorial covers every method for importing existing GitHub projects into Replit, including public repos, private repos, and repos with complex dependency structures. Whether you want to quickly preview someone else's open-source project or migrate your own codebase to Replit for AI-assisted development, this guide walks you through each approach. It is designed for developers transitioning from local development or another cloud IDE to Replit.
Prerequisites
- A Replit account (Starter plan works for public repos, Core/Pro for private)
- A GitHub account with access to the repository you want to import
- The repository URL from GitHub (HTTPS format)
- Basic familiarity with Git concepts (clone, push, pull)
Step-by-step guide
Import a public repo using the rapid URL method
Import a public repo using the rapid URL method
The fastest way to import a public GitHub repository is the rapid URL method. In your browser address bar, type replit.com/ followed by the full GitHub repository URL. For example: replit.com/github.com/expressjs/express. Replit automatically detects the language, creates a new Repl, clones the repository, and opens the workspace. This method works for any public repository and requires no configuration. The entire process takes about 30 seconds.
Expected result: Replit creates a new App with all files from the GitHub repository. The file tree shows the complete project structure, and the workspace is ready for editing.
Import using the guided import wizard
Import using the guided import wizard
For more control over the import process, use the guided import at replit.com/import. Click 'Import from GitHub' and paste the repository URL. If your GitHub account is not connected yet, Replit will prompt you to authorize via OAuth. Select the repository, choose whether to make the Repl public or private, and click Import. The guided method lets you preview the repository details before importing and is the recommended approach for private repositories.
Expected result: Replit shows a preview of the repository, then imports all files. The workspace opens with the project ready for configuration.
Set up a Personal Access Token for private repos
Set up a Personal Access Token for private repos
If OAuth does not work for your organization or you prefer token-based access, create a GitHub Personal Access Token (PAT) and store it in Replit. Go to github.com/settings/tokens, click 'Generate new token (classic),' select the 'repo' scope, and generate the token. Copy it immediately since GitHub only shows it once. In your Replit workspace, open the Tools sidebar, click Secrets, and add a new secret with the key GIT_URL and the value set to your repo URL with the token embedded: https://YOUR_TOKEN@github.com/user/repo.git. This allows Git operations from Shell without re-authenticating.
1# Store this as the GIT_URL secret value in Tools > Secrets:2https://ghp_your_token_here@github.com/username/private-repo.git34# Then push/pull from Shell using the secret:5git remote set-url origin $GIT_URL6git pull origin main7git push origin mainExpected result: You can push and pull from the private GitHub repository using Shell commands without being prompted for credentials.
Configure the .replit file for your imported project
Configure the .replit file for your imported project
Imported projects often need a .replit configuration file to tell Replit how to run the app. Enable 'Show hidden files' in the file tree menu to check if one was auto-generated. If not, create a .replit file in the project root. Set the entrypoint to your main file, the run command to start your application, and configure ports if it is a web server. For Node.js projects, the run command is typically 'npm install && npm start'. For Python, it is usually 'pip install -r requirements.txt && python main.py'.
1# Example .replit for a Node.js project2entrypoint = "index.js"3run = "npm install && npm start"45[nix]6channel = "stable-24_05"78[[ports]]9localPort = 300010externalPort = 80Expected result: Pressing the Run button installs dependencies and starts the application. The Preview pane shows your running app.
Install system-level dependencies with replit.nix
Install system-level dependencies with replit.nix
Some imported projects require system packages that are not available by default in Replit. For example, a project using Sharp for image processing needs the vips library. Create or edit the replit.nix file in your project root to declare system-level dependencies. Search for available packages at search.nixos.org/packages. After modifying replit.nix, type 'exit' in Shell to restart the environment and pick up the new packages.
1{ pkgs }: {2 deps = [3 pkgs.nodejs-20_x4 pkgs.nodePackages.typescript-language-server5 pkgs.python3116 pkgs.ffmpeg7 pkgs.imagemagick8 ];9}Expected result: After restarting Shell, the new system packages are available. You can verify by running the package command, such as 'ffmpeg --version'.
Migrate Secrets from .env files to Replit Secrets
Migrate Secrets from .env files to Replit Secrets
GitHub repositories often include a .env.example file listing required environment variables. Do not create a .env file in Replit. Instead, open Tools in the left sidebar, click Secrets, and add each variable from .env.example as a Replit Secret. Enter the key name and the actual value for your environment. Replit Secrets are AES-256 encrypted and available as standard environment variables in your code via process.env (Node.js) or os.getenv (Python). RapidDev recommends keeping a .env.example in your repo that lists all required keys without values, so new team members know which Secrets to configure.
1# If .env.example contains:2# DATABASE_URL=3# API_KEY=4# JWT_SECRET=56# Add each as a Replit Secret in Tools > Secrets:7# Key: DATABASE_URL Value: postgres://user:pass@host:5432/db8# Key: API_KEY Value: sk-your-actual-api-key9# Key: JWT_SECRET Value: your-jwt-secret-hereExpected result: Your application reads environment variables from Replit Secrets. No .env file exists in the project, keeping credentials out of version control.
Enable two-way Git sync
Enable two-way Git sync
After importing, verify that two-way sync is working. Open the Git pane (Tools > Git) and confirm you see the connected repository URL. Make a small change in Replit, commit it via the Git pane (Agent can auto-generate commit messages), and push. Then verify the change appears on GitHub. Next, make a change directly on GitHub, return to Replit, and pull from the Git pane. This confirms bidirectional sync is fully operational.
Expected result: Changes made in Replit appear on GitHub after pushing. Changes made on GitHub appear in Replit after pulling. Both directions work without authentication errors.
Complete working example
1# .replit configuration for an imported Node.js project23entrypoint = "src/index.js"4modules = ["nodejs-20:v8-20230920-bd784b9"]56# Install dependencies on first run, then start the server7run = "npm install && npm start"89# Boot command runs once when the workspace starts10onBoot = "npm install"1112[nix]13channel = "stable-24_05"14packages = ["nodejs-20_x"]1516[deployment]17run = ["sh", "-c", "npm start"]18build = ["sh", "-c", "npm install && npm run build"]19deploymentTarget = "cloudrun"2021[[ports]]22localPort = 300023externalPort = 802425# Hide clutter from the file tree26hidden = [27 ".config",28 "package-lock.json",29 "node_modules",30 ".git"31]Common mistakes when importing a GitHub repo into Replit
Why it's a problem: Creating a .env file instead of using Replit Secrets for environment variables
How to avoid: Delete the .env file and add each variable in Tools > Secrets. Replit Secrets are encrypted, .env files are not and can be accidentally committed to GitHub.
Why it's a problem: Not adding deployment secrets separately after configuring workspace secrets
How to avoid: Open the Deployments pane and add each secret that your production app needs. Workspace secrets only apply to the development environment.
Why it's a problem: Seeing 'Git Error UNAUTHENTICATED' when trying to push or pull
How to avoid: Go to replit.com/integrations, disconnect GitHub, and reconnect it. This refreshes the OAuth token and resolves most authentication errors.
Why it's a problem: Importing a large monorepo that exceeds Replit storage limits
How to avoid: Use a sparse checkout or clone only the subdirectory you need. In Shell: git sparse-checkout set path/to/subdir. Replit storage caps at 50 GiB on Core and 2 GiB on Starter.
Best practices
- Always use the guided import at replit.com/import for private repositories rather than the rapid URL method
- Store credentials in Replit Secrets (Tools > Secrets), never in .env files or hardcoded in source code
- Keep a .env.example file in the repo listing required secret names without values for team onboarding
- Configure both .replit and replit.nix immediately after import so the Run button works on first click
- Use fine-grained GitHub Personal Access Tokens with minimal permissions instead of classic tokens
- Verify two-way sync works by making a small test commit in both directions before starting development
- Add deployment secrets separately in the Deployments pane since workspace secrets do not carry over automatically
- Run 'exit' in Shell after modifying replit.nix to reload the Nix environment
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I imported a Node.js project from GitHub into Replit but the Run button does not work. The project uses Express.js with a src/index.js entrypoint. Help me create the .replit and replit.nix configuration files. The project also needs environment variables from a .env.example file.
I just imported this project from GitHub. Configure the .replit file with the correct entrypoint and run command. Check package.json for the start script. Set up replit.nix with any system dependencies the project needs. List which environment variables from .env.example I need to add to Replit Secrets.
Frequently asked questions
Yes, but you need a Replit Core ($25/mo) or Pro ($100/mo) plan. Connect your GitHub account via OAuth at replit.com/import, and Replit will list your private repositories. Alternatively, use a Personal Access Token stored in Replit Secrets for token-based access.
It creates a live connection with two-way Git sync. Changes made in Replit can be pushed to GitHub, and changes made on GitHub can be pulled into Replit. The repository is cloned into your Repl, not just copied.
The initial import clones the default branch (usually main). After importing, you can switch branches using the Git pane or by running 'git checkout branch-name' in Shell. The rapid URL method supports branch-specific imports by including /tree/branch-name in the URL.
If your .gitignore excludes .env (as it should), the file will not be imported. You need to manually add each environment variable to Replit Secrets via Tools > Secrets. Never create a .env file in Replit.
The most common causes are missing system dependencies (add them to replit.nix), missing environment variables (add them to Secrets), or a missing .replit file that tells Replit how to start the app. Check the Console output for specific error messages.
Yes, but large repos may hit storage limits. Starter plans have approximately 2 GiB storage, Core has 50 GiB. For monorepos, consider using Git sparse checkout to import only the subdirectory you need. Very large repos with extensive build artifacts may also cause slow workspace performance.
Replit's guided import only supports GitHub natively. For GitLab or Bitbucket repositories, clone the repo from Shell using 'git clone URL' after creating a blank Repl. The Git CLI tools (git, glab) are available in the Replit Shell.
Yes. The RapidDev engineering team can assist with migrating projects that have complex dependency trees, custom build pipelines, or multi-service architectures to Replit. This includes configuring Nix environments, setting up deployment pipelines, and resolving compatibility issues.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation