~/
Working with Remotes
Quiz
...

Working with Remotes

beginner · updated Tue Sep 08 2026Contribute

Learn how to add remote repositories to your project and understand the role of the origin alias in Git for efficient version control.

Working with Remotes

A remote is a version of your repository hosted elsewhere (GitHub, GitLab, etc.). origin is the default name.

Viewing Remotes

git remote -v

Shows the URLs of all configured remotes.

Adding a Remote

git remote add origin https://github.com/user/repo.git

Removing a Remote

git remote remove origin

Renaming a Remote

git remote rename origin upstream

HTTPS vs SSH

  • HTTPS: https://github.com/user/repo.git — requires token/password
  • SSH: git@github.com:user/repo.git — uses SSH keys, no password prompts

Set up SSH keys for easier authentication:

ssh-keygen -t ed25519 -C "your@email.com"

Best Practices

  • Use SSH for personal machines
  • Use HTTPS for CI/CD pipelines
  • Keep remote names consistent (origin, upstream)
  • Never commit credentials to the repository

Common Mistakes

  • Confusing origin with main
  • Pushing to the wrong remote
  • Forgetting to add a remote after cloning
  • Using unencrypted URLs with sensitive data