What is a difference between local and remote repository?

Experience Level: Junior
Tags: Git Source control

Answer

The local repository is a Git repository that is stored on your computer.

The remote repository is a Git repository that is stored on some remote computer.

The remote repository is usually used by teams as a central repository into which everyone pushes the changes from his local repository and from which everyone pulls changes to his local repository.  

When you are finished with doing changes into your workspace, you can add them to staging area and from there you can commit the changes to your local repository. This can be done even when you are disconnected from the internet and nobody else can see the changes in your local repository.

Once you decide it's a good time to share the changes, you push the changes from your local repository to the remote repository. This copies the changes from .git folder on your local computer to .git folder on the remote computer. From this moment, your changes are visible to people who have access to the remote repository.

They can pull your changes from the remote repository to their local repository and then integrate the changes into their workspaces.

In similar way you can pull changes of the others from from the remote repository to your local repository and then integrate the changes into your workspace.

Related Git job interview questions
Git for beginners
Git for beginners

Are you learning Git? Try our test we designed to help you progress faster.

Test yourself