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
- Git installed. Follow our guide →
- GitHub SSH configured. Follow our guide →
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 initExpected 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/.envdist/.DS_Store04
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}}.git06
Push your code
bash
$ git branch -M main$ git push -u origin mainExpected 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