- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is .git folder and why is it hidden?
Git is currently the most popular version control system. A version control system records the changes made to our project codebase in a special kind of file system-based database. In Git, this database is known as a repository and its structure is inspired by the Linux file system. The repository maintains a history of the changes to our codebase.
The .git folder contains all information that is necessary for the project and all information relating commits, remote repository address, etc. It also contains a log that stores the commit history. This log can help you to roll back to the desired version of the code.
The following example creates an empty git repository.
$ git init
The hidden .git folder can be viewed using the following command in the git bash terminal −
$ ls −a
The output of the command is shown below −
./ ../ .git/
The contents of the .git folder can be viewed using the tree command in a Windows Operating System.
To switch from the git bash terminal to Windows terminal, type the cmd command.
The user is presented with the Windows terminal now. Navigate to the .git folder and use the tree command to inspect the contents of this folder.
>> cd .git //Navigate to the .git hidden folder >> tree . // View contents of the current directory.
The output of the above commands can be seen in the following screenshot −
Following are a few important sub−directories and files in the .git folder −
hooks − This folder contains script files. Git hooks are the scripts that are executed before or after events like commit, push etc.
objects − This folder represents an object database of Git.
config − This is the local configuration file.
refs − This folder stores information about tags and branches.
HEAD − This file stores reference to the current branch. It points to the master branch by default.
index − This is a binary file and stores staging information
The .git folder will contain details of every single change made to the code base. All snapshots of the modifications will be recorded in this folder like a database, which makes it possible to undo the changes and rollback to the desired version of the code.
The .git folder is hidden to prevent accidental deletion or modification of the folder. The version history of the code base will be lost if this folder is deleted. This means, we will not be able to rollback changes made to the code in future.
- What is CSS and why it is used?
- What is HTML5 IndexedDB and why it is used?
- What is training? When and why it is needed?
- What is Selenium and why is it chosen extensively?
- What is data mining and why is it important
- What is cyber hygiene, and why is it important?
- What is Basant/Vasant Panchami and why it is celebrated?
- What Is the Kyoto Protocol and Why Is It Important?
- What is gestational diabetes? Why is it caused?
- What is BGP and why do we need it?
- What is SciPy and why should we use it?
- What is mundan ceremony or mundan sanskar and why is it necessary?
- What is Methanol and why is it considered an alternative cooking fuel?
- What is SEO and why it is so popular in Local businesses?
- What is emotional intelligence and why do you need it?