Beginner’s Guide: Upload Laravel Project to GitHub

Beginner’s Guide: Upload Laravel Project to GitHub

Introduction

This guide will help beginners upload a Laravel project to GitHub. By the end, your project will be online, safely stored, and ready for sharing.

Step 1: Create a GitHub Repository

  1. Go to GitHub and log in.

  2. Click + → New Repository.

  3. Fill in:

    • Repository name (e.g., Laravel-Project)

    • Visibility: Public or Private

  4. Do not check “Initialize with README”.

  5. Click Create repository.

Step 2: Open Terminal and Go to Your Project

cd /path/to/your/laravel-project

Step 3: Initialize Git

git init

Step 4: Stage and Commit Files

git add . git commit -m "Initial commit"

Step 5: Rename Branch to main (Optional)

Check branch:

git branch

Rename if needed:

git branch -m main

Step 6: Add GitHub Remote

Check if origin exists:

git remote -v
  • If it exists and is wrong:

git remote set-url origin https://github.com/YOUR_USERNAME/Laravel-Project.git
  • If it doesn’t exist:

git remote add origin https://github.com/YOUR_USERNAME/Laravel-Project.git

Step 7: Pull Remote Changes (if needed)

If GitHub has a README or other files:

git pull origin main --allow-unrelated-histories

Resolve conflicts if any, then commit.

Step 8: Push to GitHub

git push -u origin main

-u sets main as default for future pushes.

Step 9: Check Your Repository

Go to:

https://github.com/YOUR_USERNAME/Laravel-Project

You should see your Laravel project online.

Step 10: Optional – Add README.md

# Laravel Project A simple CRUD application with Laravel for learning purposes.
git add README.md git commit -m "Add README" git push

Done! Your Laravel project is now on GitHub.

Souy Soeng

Souy Soeng

Hi there 👋, I’m Soeng Souy (StarCode Kh)
-------------------------------------------
🌱 I’m currently creating a sample Laravel and React Vue Livewire
👯 I’m looking to collaborate on open-source PHP & JavaScript projects
💬 Ask me about Laravel, MySQL, or Flutter
⚡ Fun fact: I love turning ☕️ into code!

Post a Comment

CAN FEEDBACK
close