Skip to main content

How does a local repository differ from a remote one?

A local and a remote repository in Git differ in where they are stored, their purpose, and how you work with them, although from Git's point of view both hold the same data structure (commits, branches, objects).


Local repository

A local repository is a Git repository located on the developer's computer.

Typical features:

  • located in the project directory and the .git folder
  • contains the full commit history
  • has a working directory with the project's files
  • allows working without internet access
  • used for:
    • editing files
    • creating commits
    • experimenting with branches
    • locally rolling back changes

All changes land in the local repository first.


Remote repository

A remote repository is a Git repository located on a server (GitHub, GitLab, Bitbucket, a corporate server).

Typical features:

  • accessible over the network
  • most often a bare repository (without a working directory)
  • used as an exchange point between developers
  • serves as a backup copy of the project
  • not edited directly, changes reach it only through push

Key differences

1. Storage location

  • local - on the developer's computer
  • remote - on a server

2. Purpose

  • local - working with code and the change history
  • remote - synchronization and collaboration

3. Working directory

  • local - has the project's files
  • remote - usually absent

4. Dependency on the internet

  • local - not required
  • remote - required for access

5. Creating commits

  • local - commits are created
  • remote - commits are only accepted

How they interact

  • changes are created locally
  • git push sends commits to the remote repository
  • git fetch / git pull retrieves commits from the remote into the local one

Summary

A local repository is the developer's workspace with the full history and the project's files. A remote repository is a server-side copy of the repository, used for exchanging changes, collaboration, and storing the project's history.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.