Connecting and Pushing a Local Repository

Use the empty repository you just created on GitHub. Start in your local project-notes directory with main checked out and at least one commit.

On this page

Connect the remote URL

Copy the repository’s HTTPS URL from GitHub. Replace OWNER with your actual account or organization name. Run git remote -v first. If origin already exists, check where it points. Use git remote set-url origin followed by the new URL only if origin should point to this repository.

git remote -v
git remote add origin https://github.com/OWNER/project-notes.git
git remote -v

Authenticate and push main

Push your local main and configure it to track origin/main. For HTTPS, Git Credential Manager can open a browser sign-in. A personal access token can be used in place of a password when appropriate. If you use the SSH URL, add your public SSH key to GitHub and keep the private key on your own machine. After pushing, refresh the repository’s Code tab to see the committed files.

git push -u origin main
git status -sb

Official references