Push local project to new GitHub repository

GitHub
Windows
Steps to push a local project to a new GitHub repository for the first time.
Published

May 28, 2026

Overview

Starting point: a local project with no remote repository.
Goal: push it to a new GitHub repository from scratch.

Prerequisites

Create the repository on GitHub

Create a new repository with these settings:

  • Name: my-repo-name
  • Visibility: Private or Public (worth deciding upfront)
  • Leave Add README, Add .gitignore, and Add license unchecked — adding any of these creates a commit on the remote, which complicates the initial push from a non-empty local repo.

Check the .gitignore before pushing

Make sure the .gitignore at the root of the project excludes build artifacts, caches, and environment files. Crucially, any file containing secrets or credentials should be listed there — pushing sensitive information to GitHub, even a private repo, is a real security risk.

A good starting point for Python projects is the official Python.gitignore template.

Push the local project

Replace my-repo-name with the actual repository name and USERNAME with the GitHub username.
Run the git commands from the project folder.
The git push step may prompt for a GitHub authentication.

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/USERNAME/my-repo-name.git
git push -u origin main

Verify what landed on the remote

Once the push completes, confirm the remote has the right files:

git pull
git ls-tree -r --name-only HEAD
Output example:
.gitignore
.python-version
function_app.py
host.json
requirements.txt