Pushing a project to GitHub is one of the most fundamental skills for any developer, whether you’re working solo, collaborating with a team, or building a portfolio. GitHub not only provides a backup of your code but also allows others to contribute, review, and collaborate with you.
In this guide, you’ll learn how to push a local project to GitHub using Git in just a few easy steps.
✅ Prerequisites
Before you start, make sure you have the following:
- Git installed
- A GitHub account
- A local project (folder with code/files)
📦 Step 1: Create a New Repository on GitHub
- Go to https://github.com
- Click the “+” icon in the top-right corner → Select “New repository”
- Fill in the repository name, description, visibility (public/private), and click Create repository
📝 Don’t initialize with a README if you’re pushing an existing project — it can cause conflicts.
💻 Step 2: Open Terminal and Navigate to Your Project
cd path/to/your/project
Example:
cd Desktop/my-awesome-project
🔧 Step 3: Initialize Git (If Not Already Initialized)
If you haven’t run Git in this project before:
git init
This creates a .git
folder, making it a Git-tracked project.
📂 Step 4: Add Your Files to Git
git add .
This stages all files in your project for commit.
✏️ Step 5: Commit Your Changes
git commit -m "Initial commit"
This creates a snapshot of your project history.
🌐 Step 6: Link to the Remote GitHub Repository
Copy the repository URL from GitHub (either HTTPS or SSH).
Then, link it:
git remote add origin https://github.com/yourusername/your-repo-name.git
🔐 Use HTTPS if you’re not familiar with SSH keys.
🚀 Step 7: Push the Project to GitHub
Now push your local project to GitHub:
git push -u origin main
If your default branch is
master
, use:
git push -u origin master
🧠 Summary of Commands
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
✅ Final Thoughts
Now your project is live on GitHub! You can share it, collaborate with others, or keep working and push more updates as you go:
git add .
git commit -m "Your message"
git push
Pushing to GitHub is an essential skill that becomes second nature with practice. As you build more projects, version control will save you time and headaches.