Skip to main content

Repository

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/repository

In short

A repository is the storage location for a project, holding all of its files plus the complete history of every change recorded by a version control system.

What is a repository in Git?

A repository, usually called a repo, is the home of a project under version control. It contains the project's files plus a record of every commit, branch, and tag, so you can see how the code has changed over time and recover any earlier version. In Git, this history lives in a hidden .git folder at the root of the project.

Git repositories come in two flavors. A local repository lives on your own computer, where you edit files and make commits. A remote repository is hosted on a server or a platform such as GitHub, GitLab, or Bitbucket, and it acts as the shared copy the team synchronizes with using git push, git pull, and git fetch. You create a new repository with git init, or copy an existing one, history included, with git clone.

A repository is like a library archive for a book that keeps not only the latest edition but every draft ever written, with notes on who changed what and why. Because Git is distributed, every clone is a complete repository with the full history, so work can continue even if the central server goes down.

People often use the word repository to mean the project page on a site like GitHub, but the repository is really the files plus their history, wherever they are stored. A repository is also different from a fork, which is a copy of someone else's repository under your own account. Package registries such as npm are sometimes loosely called repositories too, but they store published packages rather than source code history.

Key takeaways

  • A repository stores a project's files together with their complete change history.
  • Git keeps that history in a hidden .git directory.
  • Local repositories live on your machine; remote repositories are hosted for sharing.
  • git init creates a new repository, and git clone copies an existing one.
  • Every Git clone is a full repository, not just a snapshot of the latest files.

Example

Creating, cloning, and inspecting repositoriesbash
# Create a new, empty repository in the current folder
git init

# Or copy an existing remote repository, including its full history
git clone https://github.com/example/my-project.git
cd my-project

# List the remote repositories this clone is connected to
git remote -v

# Download new commits from the remote without changing your files
git fetch origin

Readers ask

What is the difference between a local and a remote repository?

A local repository is the copy on your own computer, where you make commits. A remote repository is hosted elsewhere, such as on GitHub or a company server, and you sync with it using git push and git pull.

What is the difference between cloning and forking a repository?

Cloning downloads a copy of a repository to your computer with git clone. Forking is a hosting platform feature that creates a copy of someone else's repository under your own account on that platform, which you then usually clone to work on.

What is a bare repository?

A bare repository contains only Git's history data, without a working copy of the files, and is created with git init --bare. It is typically used on servers as a central repository that people push to and pull from.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings