Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a repository the .git folder or directory with .git folder?

Tags:

git

According to https://www.git-tower.com/learn/git/ebook/en/command-line/basics/basic-workflow#start

In Git, the repository is just a simple hidden folder named ".git" in the root directory of your project.

But Git for beginners: The definitive practical guide says

A git repository is simply a directory containing a special .git directory

Does "repository" refer to the hidden .git folder or the directory containing a .git directory?

I know that when you git commit, you are logging changes into your local .git folder. Does this mean when we push to a remote repository like one hosted on GitHub, we are just pushing the contents of the .git folder and nothing else?

like image 214
csguy Avatar asked Oct 17 '25 13:10

csguy


1 Answers

Does "repository" refer to the hidden .git folder or the directory containing a .git directory?

In strict sense the repository is only .git/ subdirectory. The directory that contains .git/ and all project files is called "working tree", and in strict sense .git/ subdirectory doesn't belong to the working tree.

But people are people, we use relaxed terminology, so we often call the entire working tree + .git/ "repository" or "project" or whatever.

I know that when you git commit, you are logging changes into your local .git folder. Does this mean when we push to a remote repository like one hosted on GitHub, we are just pushing the contents of the .git folder and nothing else?

Short answer: yes.

Longer answer is complex. Yes, git push only pushes objects from Git object database, and pushes references (branches and tags). But there are more things in .git/ that are never pushed or pulled: the config file, hooks and many other files and directories related to the current repository.

like image 161
phd Avatar answered Oct 20 '25 04:10

phd