What is a remote repository in Git?
A remote repository in Git is a copy of a Git repository that lives not on your computer, but somewhere else: on a server on a network, in corporate infrastructure, or on a hosting service such as GitHub/GitLab/Bitbucket. It exists not "for Git to work" as such (Git works perfectly well locally), but for exchanging changes and collaborating, as well as serving as a central storage/backup.
What exactly is stored in a remote repository
A remote repository stores:
- commits (the history of changes),
- branches (references to commits),
- tags,
- Git's internal data (objects, references).
Important: a remote repository is not "a folder of files", it is a Git object database, just like a local repository.
Most often, a remote repository on a server is set up as a bare repository (without a working directory with unpacked files). This is normal: on a server, files are usually not edited directly, only commits are accepted and handed out.
How a local repository differs from a remote one
Local repository (on your machine)
- contains your local history and branches,
- has a working directory (the project's files),
- you make commits locally, even without internet access.
Remote repository (on a server)
- serves as a synchronization point between participants,
- lets you publish your changes and pull in others' changes,
- is often treated as the "source of truth" for the project.
Git is distributed by nature: every developer has a full-fledged repository. The remote is just a convenient shared exchange point.
Why a remote repository is needed
- Collaboration
- one developer sends changes, another pulls them and continues working.
- Exchange and synchronization
- publishing your branches/commits for the team.
- Backup storage
- if your laptop breaks, the history stays on the server.
- Development processes
- Pull/Merge Requests, code review, CI/CD, checks, releases - all of this is usually tied to the remote repository.
- Separation of responsibility
- locally you can experiment, and you only send finished work to the remote.
How Git "sees" a remote repository: remotes
In Git, remote repositories are configured as a remote - a record consisting of:
- a name (often
origin) - a URL (the address to connect to)
Example: when you run git clone, Git automatically creates a remote named origin, pointing to the source you cloned from.
What origin is
origin is just a standard name, not "a special server". A remote can be named anything (upstream, company, backup).
How you connect to a remote repository (protocols)
Commonly used:
- HTTPS (convenient, tokens/passwords)
- SSH (convenient for developers: keys, less hassle with tokens)
- less often:
git://and other options
The choice of protocol affects the authentication method, but the essence of the remote repository does not change.
A typical workflow with a remote repository
- Pull the team's current changes:
fetchorpull - Create/update your branch
- Commit locally
- Push the branch to the server:
push - Open a Merge/Pull Request
- After review, merge into the main branch
- Everyone else pulls the changes (
pull/fetch)
Important points and frequent mistakes
- A remote repository does not update itself: changes appear on the server only after a
push. pullcan lead to conflicts because it tries to apply changes immediately.fetchis safer when you want to first see what has changed and only then decide how to integrate it.- "Delete a file locally" ≠ "delete it on the server": it only reaches the server after a commit and a
push. - You cannot "push" what is not in any commit:
pushsends commits, not "the state of a folder".
Short final definition
A remote repository in Git is a Git repository located on a server that serves as a point of exchange and synchronization: you send your commits to it (push) and receive other people's commits (fetch/pull), enabling collaboration and backup storage of the project's history.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.