Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the .git folder?

Tags:

git

What is the folder called .git?

It's created in a repository. What is contained within it and why is created?

like image 282
Omega Avatar asked Mar 23 '15 18:03

Omega


People also ask

Is it safe to delete .git folder?

Since all our files are specific to this particular repository, it will find nothing related to it in the parent directory. So, if you have not cloned your project, it is better not to delete the . git folder. Although, you can fetch a few things saved inside the parent directory.

What happens when I delete .git folder?

The folder is created when the project is initialized (using git init ) or cloned (using git clone ). It is located at the root of the Git project repository. If we delete the . git folder, the information saved by Git will be lost, and the directory will no longer act as a Git repository.

Where is .git folder located?

By default . git directory is hidden inside working directory in windows.

What are the files in the .git directory?

The . git folder contains all the information that is necessary for your project in version control and all the information about commits, remote repository address, etc. All of them are present in this folder. It also contains a log that stores your commit history so that you can roll back to history.


2 Answers

.git is initialized by git init.

.git contains all information required for version control. If you want to clone your repo, copy .git is enough.

4 sub-directories:

  • hooks/ : example scripts
  • info/ : exclude file for ignored patterns
  • objects/ : all "objects"
  • refs/ : pointers to commit objects

4 files:

  • HEAD : current branch
  • config : configuration options
  • description
  • index : staging area

Here "object" includes:

  • blobs(files)
  • trees(directories)
  • commits(reference to a tree, parent commit, etc)
like image 116
GraceMeng Avatar answered Oct 08 '22 05:10

GraceMeng


The .git folder contains all the information that is necessary for your project in version control and all the information about commits, remote repository address, etc. All of them are present in this folder. It also contains a log that stores your commit history so that you can roll back to history.

For more info, you can check the official website of git.

like image 39
Avinash Ranjan Avatar answered Oct 08 '22 04:10

Avinash Ranjan