Push local project to new GitHub repository
Overview
Starting point: a local project with no remote repository.
Goal: push it to a new GitHub repository from scratch.
Prerequisites
- A GitHub account — GitHub signup, it’s free.
- Git installed locally — Git for Windows.
- A local folder with the project to push.
Create the repository on GitHub
Create a new repository with these settings:
- Name:
my-repo-name - Visibility:
PrivateorPublic(worth deciding upfront) - Leave
Add README,Add .gitignore, andAdd licenseunchecked — 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 mainVerify 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.gitignore .python-version function_app.py host.json requirements.txt