Learn Version Control with Git
A step-by-step course for the complete beginner
About Remote Repositories
About 90% of version control related work happens in the local repository: staging, committing, viewing the status or the log/history, etc. Moreover, if you're the only person working on your project, chances are you'll never need to set up a remote repository.
Only when it comes to sharing data with your teammates, a remote repo comes into play. Think of it like a "file server" that you use to exchange data with your colleagues.
Let's look at the few things that distinguish local and remote repositories from each other:
Local repositories reside on the computers of team members. In contrast, remote repositories are hosted on a server that is accessible for all team members - most likely on the internet or on a local network.
Technically, a remote repository doesn't differ from a local one: it contains branches, commits, and tags just like a local repository. However, a local repository has a working copy associated with it: a directory where some version of your project's files is checked out for you to work with.
A remote repository doesn't have such a working directory: it only consists of the bare ".git" repository folder.
It's important to stress that the actual work on your project happens only in your local repository: all modifications have to be made & committed locally.
Then, those changes can be uploaded to a remote repository in order to share them with your team. Remote repositories are only thought as a means for sharing and exchanging code between developers - not for actually working on files.
Creating a remote repository can be done in two ways: if you already have a local repository that you want to base it on, you can clone this local one with the "--bare" option on your command line. In case you want to create a blank remote repository, you can use the "git init" command, also with the "--bare" option, on your command line.
Local / Remote Workflow
In Git, there are only a mere handful of commands that interact with a remote repository.
The overwhelming majority of work happens in the local repository. Until this point (except when we cloned a remote repo), we've worked exclusively with our local Git repository and never left our local computer. We were not dependent on any internet or network connection but instead worked completely offline.
We'll look at each of these commands in the course of the following sections.