If you’ve ever built a project and wanted to share it online, collaborate with others, or simply back it up safely, GitHub is where it all begins. It’s the most popular platform for hosting code repositories — used by millions of developers, teams, and organizations worldwide.
But if you’re new to Git or GitHub, pushing your project to the cloud for the first time can seem confusing. Questions like “What’s a repository?”, “Do I need Git installed?”, and “How do I connect my local project to GitHub?” are extremely common.
In this step-by-step guide, we’ll show you how to push your local project to GitHub the right way — from creating your first repository to syncing it using Git commands or Visual Studio Code.
What is GitHub?
Before jumping into the process, let’s quickly understand what GitHub is and why it matters.
GitHub is a cloud-based hosting platform built around Git, a version control system that helps developers track and manage changes in their code.
In simple terms:
- Git manages your project’s history on your computer.
- GitHub stores that history online so others (or future you) can access it anytime.
When you push a project to GitHub, you’re uploading your local files and commits to a remote repository — like saving your progress to the cloud.
What You’ll Need
Before pushing your project to GitHub, make sure you have:
- A GitHub account (Sign up at github.com)
- Git installed on your PC (Download Git here)
- A local project folder (any code or file you want to upload)
- Optionally: Visual Studio Code (VS Code), if you prefer a graphical interface
Once these prerequisites are ready, you can start setting up your repository.
Step 1: Create a New Repository on GitHub
The first step is to create a new repository where your project will live.
- Go to https://github.com and sign in to your account.
- Click the + icon in the top-right corner → select New repository.
- Enter a Repository name (for example,
my-first-project). - Add a description (optional but recommended).
- Choose between:
- Public – anyone can see your repository.
- Private – only you (and invited collaborators) can access it.
- (Optional) Check:
- Add a README file (helps describe your project)
- Add .gitignore (to exclude unnecessary files)
- Choose a license (if you’re sharing publicly)
- Click Create repository.
Your new repository is now live on GitHub — time to connect it to your local project.
Step 2: Initialize Git in Your Local Project
Next, you need to tell Git to start tracking your project locally.
- Open Command Prompt, PowerShell, or Terminal.
- Navigate to your project folder:
cd path/to/your/project - Initialize Git:
git initThis creates a hidden.gitfolder in your project directory — which Git uses to track changes. - Add all files to the staging area:
git add . - Commit your files with a message:
git commit -m "Initial commit"This saves your current project snapshot in Git’s history.
Step 3: Connect Your Local Repository to GitHub
Now that your project is initialized locally, you need to connect it to the GitHub repository you created.
- Go to your GitHub repository page.
- Click the Code button → copy the HTTPS URL (e.g.,
https://github.com/username/my-first-project.git). - In your terminal, run:
git remote add origin https://github.com/username/my-first-project.gitThis command links your local Git repository to the remote one on GitHub.
To confirm the connection:
git remote -v
You should see:
origin https://github.com/username/my-first-project.git (fetch)
origin https://github.com/username/my-first-project.git (push)
Step 4: Push Your Project to GitHub
Now comes the fun part — pushing your project online!
- Run the following command:
git push -u origin main(If your default branch is “master”, replacemainwithmaster.) - Git will prompt you to enter your GitHub username and personal access token (PAT) for authentication.
- If you haven’t created one yet, go to: https://github.com/settings/tokens
- Generate a classic token, give it repo permissions, and copy it.
- Once authenticated, Git will upload all your commits and files to GitHub.
- Visit your GitHub repository page — you should now see your entire project there!
Step 5: Push Future Updates to GitHub
Once you’ve linked your local and remote repositories, pushing future changes becomes super easy.
Whenever you make new changes:
- Stage them:
git add . - Commit them:
git commit -m "Updated feature X or fixed bug Y" - Push to GitHub:
git push
That’s it — your GitHub repository stays up to date automatically.
Step 6 (Optional): Push a Project Using Visual Studio Code
If you prefer a more visual way to work with Git, Visual Studio Code makes it even easier.
Here’s how:
- Open your project in VS Code.
- Click the Source Control icon (or press
Ctrl + Shift + G). - Click Initialize Repository (if not already done).
- Write your first commit message → click the checkmark icon to commit.
- Click Publish to GitHub (VS Code will ask for authentication).
- Once connected, your project will automatically upload to your GitHub account.
Every time you make changes, you can commit and push directly from VS Code with just a few clicks.
Wrapping Up
And there you have it — a complete guide on how to push a project to GitHub! Whether you’re uploading your very first code project or collaborating with a team, pushing your project to GitHub is one of the most important skills every developer should learn.
You can do it via command line, Visual Studio Code, or even GitHub Desktop, depending on your preference. Once set up, syncing your work takes just a few seconds.