Lesson 3 / 20
Connect a Local Repo
Connect a local Git repository to GitHub with git remote add and push it with upstream tracking.
By Rahul Agarwal · 15 years in web development · Updated 1 Oct 2026
Add the remote
git remote add origin points your local repo at the GitHub repo's URL. origin is just the conventional name for it.
git remote add origin https://github.com/username/my-app.git
git remote -vPush for the first time
-u sets the upstream branch, so future git push / git pull need no arguments.
git push -u origin mainHTTPS vs SSH
HTTPS asks for a token or password unless cached; an SSH key lets you push without typing credentials each time.