How to Push a Project to GitHub

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.

  1. Go to https://github.com and sign in to your account.
  2. Click the + icon in the top-right corner → select New repository.
  3. Enter a Repository name (for example, my-first-project).
  4. Add a description (optional but recommended).
  5. Choose between:
    • Public – anyone can see your repository.
    • Private – only you (and invited collaborators) can access it.
  6. (Optional) Check:
    • Add a README file (helps describe your project)
    • Add .gitignore (to exclude unnecessary files)
    • Choose a license (if you’re sharing publicly)
  7. 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.

  1. Open Command Prompt, PowerShell, or Terminal.
  2. Navigate to your project folder: cd path/to/your/project
  3. Initialize Git: git init This creates a hidden .git folder in your project directory — which Git uses to track changes.
  4. Add all files to the staging area: git add .
  5. 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.

  1. Go to your GitHub repository page.
  2. Click the Code button → copy the HTTPS URL (e.g., https://github.com/username/my-first-project.git).
  3. In your terminal, run: git remote add origin https://github.com/username/my-first-project.git This 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!

  1. Run the following command: git push -u origin main (If your default branch is “master”, replace main with master.)
  2. Git will prompt you to enter your GitHub username and personal access token (PAT) for authentication.
  3. Once authenticated, Git will upload all your commits and files to GitHub.
  4. 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:

  1. Stage them: git add .
  2. Commit them: git commit -m "Updated feature X or fixed bug Y"
  3. 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:

  1. Open your project in VS Code.
  2. Click the Source Control icon (or press Ctrl + Shift + G).
  3. Click Initialize Repository (if not already done).
  4. Write your first commit message → click the checkmark icon to commit.
  5. Click Publish to GitHub (VS Code will ask for authentication).
  6. 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.

Posted by Arpita

With a background in Computer Science, she is passionate about sharing practical programming tips and tech know-how. From writing clean code to solving everyday tech problems, she breaks down complex topics into approachable guides that help others learn and grow.