Elena' s AI Blog

Git Remotes

24 Jun 2024 (updated: 05 Oct 2026) / 10 minutes to read

Elena Daehnhardt

Midjourney AI-generated art, June 2024: teamwork with many computers, Bob and Alice work together, HD, Canon lens


TL;DR:
  • Use 'git remote add origin URL' to connect repos, 'git fetch' to update, 'git push' to share changes. Remotes enable backup, collaboration, and version control—essential for team workflows.

Previous: Part 23 — The Token Way to GitHub Security

Next: Part 25 — Git Checkout for overwriting directories from different branches

Overview: Managing Git Remote Repositories

This post is about managing remote repositories in Git. We explore tasks such as adding, renaming, removing remotes, and updating remote URLs. We also practice fetching, pulling, and pushing changes to and from remote repositories.

What Are Git Remotes? Definition and Purpose

A Git remote is a named reference to a version of your repository hosted on another computer or platform such as GitHub or Bitbucket. Git remotes connect your local project to those copies, letting you back up, share, and synchronise your code across machines.

Are Git Remotes similar to Git branches? Remotes are not branches, but they work together. Branches are like alternate timelines within your repository, while remotes are links to entirely different repositories (potentially with their own sets of branches). You can have branches on your local and remote repositories, and Git helps keep them in sync.

Git Remote Commands Reference

The most useful commands for working with Git Remotes are (see Git Basics - Working with Remotes):

  • git remote add <name> <url>: Adds a new remote.
  • git remote show <name>: Inspects a remote.
  • git remote -v: Shows your remotes and their URLs.
  • git fetch <name>: Gets updates from the remote without merging.
  • git pull <name> <branch>: Downloads and merges remote changes.
  • git push <name> <branch>: Uploads your local changes to the remote.
  • git remote rename <old-name> <new-name>: Renames a remote.
  • git remote remove <name>: Removes a remote.
  • git remote set-url <name> <new-url>: Updates a remote’s URL.

The fix for the origin error, best practices for solo and team work, and token authentication follow below.

Using Git Remotes: Best Practices

🔒 Subscribe to keep reading.

Using Personal Access Tokens for Git Authentication

🔒 Subscribe to keep reading.

Conclusion

🔒 Subscribe to keep reading.

References

🔒 Subscribe to keep reading.

You've hit a Deep Dive tutorial.

I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.





Citation
Elena Daehnhardt. (2024) 'Git Remotes', daehnhardt.com, 24 June 2024. Available at: https://daehnhardt.com/blog/2024/06/24/git-remotes/
All Posts