~/hackweb.dev
Working with Remotes
Quiz
...

Working with Remotes

beginner · updated Tue Sep 08 2026Contribute

Add remote repositories and understand origin.

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: [email protected]:user/repo.git — uses SSH keys, no password prompts

Set up SSH keys for easier authentication:

ssh-keygen -t ed25519 -C "[email protected]"

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