Git Remote & GitHub

Push your repository online.

✍️ 2 exercises in this lesson

A remote is a copy of your repository hosted elsewhere, usually on GitHub.

  1. Create an empty repository on GitHub.
  2. Connect it: git remote add origin https://github.com/you/my-project.git
  3. Upload: git push -u origin main (-u remembers the link for next time).

git remote -v lists remotes. Authentication uses a browser login, a personal access token or SSH keys.

Key Takeaways: Git Remote & GitHub

Mastering Git Remote & GitHub helps you write clean and reliable Git code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Git Remote & GitHub Code Example

Git
git remote add origin https://github.com/alikhan/my-project.git
git push -u origin main
Output
Enumerating objects: 9, done.
Writing objects: 100% (9/9), 812 bytes | 812.00 KiB/s, done.
To https://github.com/alikhan/my-project.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

Git Remote & GitHub Practice Exercises

Check what you learned in “Git Remote & GitHub”.

/ 2 solved
Fill in the blank

Connect the local repository to GitHub.

git remote  origin https://github.com/you/project.git
✓ Correct! Not quite. Try again.
Multiple choice

What does -u do in "git push -u origin main"?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services