I build a lot of apps in Replit. Then I push them to GitHub. Then I deploy the app to AWS. Then I do it again. I've probably done this exact workflow a thousand times across different projects. Also: version control has saved my career more than once. Hard drives fail, servers hiccup, and sometimes you just need to see what the code looked like last Tuesday.
Why would one want to do this? Well, as with any tool or service Replit solves a very specific use case that doesn't fit all. The majority of my projects
Before you start
You'll need:
- A GitHub account
- A Replit project (your "Repl")
The Easy Way
- In Replit, open the Git tab.
- Click Create Remote
- Choose GitHub / Personal
- Name your repository a sane name. I like to use the domain of the site I'm working on or the name of the Replit to disambiguate things.
- Make sure your set it to Private unless you want the whole world to see your secrets!
- Smash that Create button and there you go!
Keep in mind you'll want to sync your changes periodically from Replit to GitHub. The sync button is towards the top of the Git tab.
The hard way
Sometimes the Replit GUI starts acting up, and the only way around it is to dive in to the Shell and hack it back into submission.
Step 1: Click the Shell tab.
Then confirm you're in the project's root directory. This command should list the same files/folders you see in the file explorer.
pwd
ls
Step 2: Initialize Git (if needed)
Git is one of those tools that can do about a million things, but 99% of the time you're using the same five commands.
Some Repls already have Git set up. If not:
git init
git status
Step 3: Add a .gitignore (Python example)
This keeps junk out of your repo. Create or edit .gitignore with the following content:
echo "__pycache__/
.env
.venv
*.pyc" > .gitignore
Commit it:
git add .gitignore
git commit -m "Add gitignore"
Step 4: Connect to GitHub
Copy your repo URL from GitHub (HTTPS is simplest). Then:
git remote add origin https://github.com/YOUR_USER/YOUR_REPO.git
git branch -M main
That last line renames your branch to main.
Step 5: Push
git push -u origin main
If authentication gets weird: GitHub now prefers tokens over passwords. Replit may prompt you with a browser flow, or you may need to create a Personal Access Token. GitHub will walk you through this if you get stuck. They've gotten pretty good at the browser flow thing.
If Git complains about missing name/email, set them with:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
The usual suspects when things break
- Did you commit before pushing?
- Is your remote correct?
git remote -v
- Are you pushing the right branch?
git branch
Once you've done this a few times, it becomes muscle memory. Like riding a bike, except the bike randomly demands new passwords.
If you're looking to connect your Replit app to external services like databases or storage, check out my guides on connecting to AWS RDS PostgreSQL, AWS S3 for object storage, or sending emails with AWS SES.
-Sethers