7. Remotes and GitHub

What is a remote repository?

So far, we've been working with a local repository that exists only on our computer. But one of the most powerful features of Git is the ability to synchronize your repository with a remote repository hosted on some distant server. This is why Git is called a distributed version control system.

A remote repository is simply a version of your project that is hosted elsewhere. It's not any different from your local repository, except that it's always connected to the network and can be accessed by others.

Here's how a remote repository fits into the picture:

  1. Suppose that we started a new project and created a local repository on the computer. We've been working on it for a while, and now we want to share the work with others.

  2. We create a remote repository on a server such as GitHub, and push our local repository to it. Pushing changes means transferring commits from our local repository to the remote repository.

  3. Now, other people can clone the remote repository to their local machines. As the name suggests, cloning a repository means creating a copy of the repository on a local machine.

  4. After someone has cloned our repository, they have an identical copy of the repository on their machine. But if they make any new changes, these changes remain local to their machine until they push them to the remote repository.

  5. Say someone else has pushed new changes to our remote repository. We can pull these changes to our own local repository. Pulling changes means transferring commits from the remote repository to our local repository.

Of course, if we own the remote repository, we can control access to it. For example, for an open-source project, it's common to allow anyone to clone the repository, but only selected people (called maintainers) can push new changes to it.

Platforms like GitHub go a step further and let others fork our repository. A fork is a separate copy of the repository under someone else's account. For example, if someone found an error in our project and wants to help us fix it, they can fork our entire project, fix the error in their forked version, and then suggest the fix to us by creating a pull request (also called a merge request). If we like the changes, we can then merge these changes into our repository.

That's intriguing!

Projects like Linux, .NET, Python, and even VS Code itself are all being developed in this exact way. Anyone can fork these repositories, develop their own features, and then suggest these features to the maintainers in the form of pull requests.

If you're fascinated by all of this, stick around until Part II of the course, where I'll cover some very interesting topics about collaboration and open-source development.

Let's recap

With a remote repository, you can:

  • Share your work with others: By pushing your changes to a remote repository, you make them available for others to see and work with. They, in turn, pull your changes into their local repositories. The remote repository serves as a central point where everyone can share their work.

  • Back up your work: Even if something happens to your local machine, your work is safe on the remote server.

  • Access your work from anywhere: As long as you have an Internet connection, you can fetch your latest work from the remote repository to any machine. For example, if you started your work on a work computer, you can continue it on your home computer, and vice versa.

The most popular platform for hosting Git repositories is GitHub. Currently, it's the largest host of source code in the world. It's free to use for public repositories, and it's a great place to share your work with others.

Let's see how you can create a new repository on GitHub.

Next step
© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

This page is a part of the interactive course about Git version control.

It's a one-of-a-kind course that is integrated into the VS Code code editor. Learning directly in VS Code lets you operate Git exactly as you would in real life, doing real jobs, writing real code.

In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code