Git is a Version Control System that keep track of changes to your files & collaborate with others on project.
Git is a Content Addressable Filesystem - Git is a simple key-value data store. Git is like a special storage system where you can save any content (like files or data). When you save something in Git, it gives you a unique key (a SHA-1 hash - 40-character strings) for that content. You can use this key to retrieve the exact content you saved whenever you need it.
Imagine you have a library where every book is given a unique code. When you want to find a book, you just use its code to locate it. Similarly, in Git, you save a file, get a unique key, and use that key to get the file back whenever you need it.
git init is a command that initializes a new Git repository. When you run this command in a directory, it sets up the necessary files and structure for Git to start tracking changes in that directory.
Steps and Effects of Running git init
$ tree .git
.git
├── config
├── HEAD
├── hooks
│ └── prepare-commit-msg.msample
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
- We’ll also look at the .git directory structure after the commit. Let’s add a text file named gitText.txt and commit it. This process will return a unique ID for the commit.
- HEAD - Tracks the current branch or commit. It updates automatically when you switch branches or checkout a commit.
Think of the HEAD file as a bookmark in a book. The bookmark tells you which page (branch or commit) you are currently on.
- config - Text file that contains your git configuration for the current repo. If you look into it, you would see some basic settings for you repo like the author, filemode etc.
- refs - In Git, refs (references) are pointers to commits, making it easier to manage your repository. They are stored in the .git/refs directory and help keep track of branches, tags, and remote branches. Each ref file contains the commit hash it points to, helping you navigate and manage your project’s history.
- objects - The objects directory in Git stores data about your files and commits.
Here’s how it works: Use the git log command to see all your commits.
This file contains all the information about that specific commit. This structure helps Git organize and find commit data efficiently.
objects/
├── 8d/
│ └── 168052de87b8bd8b71211383cd17457f0e2267
- logs - Git logs track the changes made to your refs over time. They help you understand the sequence of commits and actions taken in your repository.
- hooks - It contain any scripts that can be run before/after git does anything. It is like a little helper to automate the tasks.
Client-side hooks - which run on your local machine and are triggered by actions like committing or merging
Server-side hooks - which run on the server where your repository is hosted and are triggered by actions like pushing commits (e.g., pre-receive to enforce rules before accepting commits).
To use a hook, you typically rename a sample script in the .git/hooks directory by removing the .sample extension and making it executable. This allows you to customize and automate your Git workflow effectively.

SOCIAL SHARE CARD GENERATOR