Skip to main content

Command Palette

Search for a command to run...

From Replit to GitHub: Push Your First Project Online

Updated
3 min read
From Replit to GitHub: Push Your First Project Online
M

Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).

You’ve learned how to branch, stash, tag, and merge in your Replit project. Great work! But right now, your project only lives in Replit. What if your browser crashes? Or you want to show off your work to others? That’s where GitHub comes in.

In this hands-on tutorial, you’ll publish your Replit project to GitHub — even if you’ve never made a GitHub account before.

Step 0: Create a GitHub Account

[.1] Go to github.com.
[.2] Click Sign up.

You’ll be asked for:

  • Username → Pick something simple (e.g., smartcomputing123).

  • Email → Use a valid one, GitHub will send confirmation here.

  • Password → Strong and unique.

Confirm your email and you’re in!

Step 1: Create a New Repository on GitHub

[.1] Once logged in, click the + in the top-right → New repository.

[.2] Fill in:

  • Repository name: GitQuizDemo

  • Description: (optional) “Demo app built in Replit to practice Git branching”

  • Visibility: Public (anyone can see it) or Private (only you).

⚠️ Important: Do not check “Add a README”, .gitignore, or license.
This keeps the repo empty, so we can push from Replit without conflicts.

Click Create repository.

You’ll now see a page with instructions like:

git remote add origin https://github.com/your-username/GitQuizDemo.git
git branch -M main
git push -u origin main

Keep this page open — we’ll need the commands.

In your Replit project Shell:

  1. Make sure you’re in the project root.

     pwd
     ls
    

    You should see your index.php.

  2. Add the GitHub repo as a remote. Replace your-username with your GitHub username:

     git remote add origin https://github.com/your-username/GitQuizDemo.git
    
  3. Confirm it’s added:

     git remote -v
    

    Output should show origin pointing to your GitHub repo.

Step 3: Push Your Local Commits to GitHub

Now push your project:

git branch -M main
git push -u origin main

You’ll be prompted for your GitHub login. Since GitHub no longer accepts passwords over HTTPS, you need a Personal Access Token (PAT).

Step 4: Generate a Personal Access Token (First-Time Setup)

[.1] On GitHub, click your profile → SettingsDeveloper settingsPersonal access tokensTokens (classic)Generate new token.
[.2] Select:

  • Expiration: 90 days (or longer if you prefer).

  • Scopes: Check repo.

Click Generate token. Copy it — you won’t see it again!

Step 5: Authenticate and Push

Back in Replit Shell:

  • When asked for Username: enter your GitHub username.

  • When asked for Password: paste your token.

If successful, you’ll see:

Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression...
To https://github.com/your-username/GitQuizDemo.git
 * [new branch]      main -> main

🎉 Congratulations! Your project is now on GitHub.

Step 6: Verify on GitHub

Go to your new repository’s URL:

https://github.com/your-username/GitQuizDemo

You should see your files (index.php, replit.nix, etc.) and commit history.

Common Mistakes & Fixes

  • Mistake: “remote origin already exists”
    Fix: Remove and re-add.

      git remote remove origin
      git remote add origin https://github.com/your-username/GitQuizDemo.git
    
  • Mistake: “failed to authenticate”
    Fix: Make sure you used your GitHub username + token, not your email + password.

  • Mistake: Repo already has README, causing conflicts
    Fix: Either delete README from GitHub or pull and merge:

      git pull origin main --allow-unrelated-histories
    

What You Learned

✅ How to create a GitHub account
✅ How to create your first repository
✅ How to link your local (Replit) project to GitHub
✅ How to generate and use a Personal Access Token for authentication
✅ How to push and verify your project online

Your Git branching practice app is now safe on GitHub, ready to share with the world!

107 views
From Replit to GitHub: Push Your First Project Online