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.
You have two options to get a local repository onto your machine: you can either create a new, empty one or clone it from an existing remote repository.
Creating a remote repository can also 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. In case you want to create a blank remote repository, use "git init", also with the "--bare" option.
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 called "git clone"), 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.
Get our popular Git Cheat Sheet for free!
You'll find the most important commands on the front and helpful best practice tips on the back. Over 100,000 developers have downloaded it to make Git a little bit easier.
As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.
Just like with Tower, our mission with this platform is to help people become better professionals.
That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.