Push an Existing Project to GitHub

Turn a local folder into a Git repository and publish it to a new GitHub repo.

beginner10 minallUpdated August 2026
#git#github#repository#developer-setup

Requirements

0/6 steps · 0%
01

Create the repository on GitHub

On GitHub, click New repository. Give it a name, leave it empty (no README, license, or .gitignore), and create it.

Important

If you initialize the new repo with a README, you'll need to merge unrelated histories later. Starting empty keeps this simple.

02

Initialize Git in your project folder

bash
$ cd {{PROJECT_PATH}}
$ git init

Expected output

Initialized empty Git repository in {{PROJECT_PATH}}/.git/
03

Add a .gitignore

Skip files you don't want tracked, like dependencies and build output.

.gitignore
node_modules/
.env
dist/
.DS_Store
04

Stage and commit your files

bash
$ git add .
$ git commit -m "Initial commit"
05

Connect the local repo to GitHub

Copy the SSH URL from your new GitHub repository's page (Code → SSH).

bash
$ git remote add origin git@github.com:{{USERNAME}}/{{REPO_NAME}}.git
06

Push your code

bash
$ git branch -M main
$ git push -u origin main

Expected output

Enumerating objects: 5, done.
Branch 'main' set up to track remote branch 'main' from 'origin'.

Success

Refresh the GitHub page — your files are now there.

Troubleshooting

A remote named `origin` is already configured, often left over from cloning a template.

bash
$ git remote set-url origin git@github.com:{{USERNAME}}/{{REPO_NAME}}.git