This blog post introduces the concept of remote repositories in Git/GitHub.

For multiple collaborators to work together on a project, the repository needs to be shared among them. In this article, we introduce the notion of a remote repository that allows us to do that.
Remote Repository
The remote repository or remote repo is a central location where a local repository is copied to and hosted on a remote server. This setup allows collaborators to retrieve files or pull the code onto their computers and work on the project even without internet access. Once the collaborators finish working on their part, they can reflect the changes in the remote repository or push the code changes. The following diagram shows how collaborators would work on a project with a remote repo.

A collaborator typically pulls the code and creates a new branch to work on a specific feature. Once the changes are made, the collaborator pushes the code and makes a pull request. The maintainer of the project checks if the branch is worth merging into the main branch and then merges it. There are multiple ways to set up a remote server to host a remote repository, and one of the easiest ways is to use GitHub.
GitHub
To set up a remote repository, we first need to create a GitHub account, navigate to the "Repositories" section, and click the "New" button. We will then be prompted to input the repository name, description, and type of the remote repo. We can choose for the remote repo to be public, which anyone can see, or private, which only chosen users can access. Once we have created the remote repo, we can use its URL, visible by clicking the "Code" button in the "Code" section, to push and pull the remote repository.
For instance, we can push code with git push <url> <branch-name>
to push the branch to the remote repo. To avoid manually typing
the same URL repeatedly, we make an alias using git remote add origin <url>
. Then, we can use origin
instead of the full URL
by running git push origin <branch-name>
. Similarly, we can pull code changes to reflect all updates in the local environment
with git pull origin <branch-name>
. When collaborators contribute to the project for the first time, they can clone
the remote repository using git clone <url>
, which creates the alias origin
for the URL automatically.
Pull Request
After collaborators are satisfied with their branch and want the maintainers to merge it into the main branch, they can push the code changes and make a pull request. After pushing the code to the branch, GitHub displays a "Make Pull Request" page in the "Code" section, where we can add a title and description of the pull request. The maintainers can review these descriptions and code changes to decide whether to merge the pull request or not. If there are any issues with the pull request, maintainers can identify the problem and notify contributors by sending text messages and highlighting pieces of code on GitHub's interface.
When contributing to an open-source project, contributors typically fork the remote repository, creating a copy of the original repo owned by the project owner, in their own GitHub accounts. Then, contributors can make changes using Git features and create pull requests to the project owner once the code is finalized. The forked repo should display a "New pull request" button where contributors can initiate a pull request to the original repository.
Conclusion
In this article, we introduced the notion of remote repositories and how we can use GitHub to host them. We also discussed how to push and pull code changes, fork a repository, and make and merge pull requests. In the next article, we will discuss extra features of GitHub for automation.
Resources
- Net Ninja. 2018. Git & GitHub Tutorial for Beginners #10 - Introduction to GitHub. YouTube.
- Net Ninja. 2018. Git & GitHub Tutorial for Beginners #11 - Collaborating on GitHub. YouTube.
- Net Ninja. 2018. Git & GitHub Tutorial for Beginners #12 - Forking (& Contributing). YouTube.