Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a "git repository" refer to precisely?

Tags:

git

Suppose my working directory working_directory has a .git hidden subdirectory (created with git init) and nothing else.

What is referred to by our "git repository"? Is it the hidden .git folder, or the entire contents of working_directory which merely includes the .git subfolder?

like image 390
George Avatar asked Aug 16 '15 00:08

George


People also ask

What does repository mean in Git?

A Git repository tracks and saves the history of all changes made to the files in a Git project. It saves this data in a directory called . git , also known as the repository folder. Git uses a version control system to track all changes made to the project and save them in the repository.

What does the Git represent?

Git, as a word, is an alternation of the word get, which itself was shortened from beget. The implicit reference is to illegitimate offspring, and the term is roughly synonymous with twit, dolt, moron or idiot.

Why do we use Git repository?

One of the biggest advantages of Git is its branching capabilities. Unlike centralized version control systems, Git branches are cheap and easy to merge. This facilitates the feature branch workflow popular with many Git users. Feature branches provide an isolated environment for every change to your codebase.


1 Answers

It is the entire contents of the working directory, that would be considered the repository.

Think about it like this: When you clone a repository, you're not just "copying" the .git folder, you're pulling down the entire "repository" in the sense of the entire root, all subfolders, and files that live in the repository.

Take a look at GitHub's awesome definition on "repository" (copied here for direct reference):

A repository is the most basic element of GitHub. They're easiest to imagine as a project's folder. A repository contains all of the project files (including documentation), and stores each file's revision history. Repositories can have multiple collaborators and can be either public or private.

Even though there is a lot of mention of "GitHub" in this answer, it is worth noting that the repository is an element of the Git SCM. Of course GitHub inherits this as well naturally, but it is a Git thing at the root of it all.

To further expand on this and to give the root definition, see the following official Git SCM definition on "repository" (copy/pasted for direct reference):

A collection of refs together with an object database containing all objects which are reachable from the refs, possibly accompanied by meta data from one or more porcelains. A repository can share an object database with other repositories via alternates mechanism.

With that being said, without knowledge of Git that definition will probably make you think you know even less of what a repository is. There are a lot of other git definitions you need to know in order to understand that particular one.

like image 153
Thomas Stringer Avatar answered Sep 26 '22 12:09

Thomas Stringer