Getting Started with Git
Opening Hackers Notebook
With Git installed, your machine is now equipped with the “Hacker’s Notebook”. A system that records every change. The first step is to initialize a repository, configure it, and create your first commit. This marks the beginning of your project’s version‑controlled history.
Creating Your First Repository
A repository (repo) is the structured notebook of your project. It stores all files, tracks history, and manages changes.
# Create a project directory
mkdir Notebook
# Navigate into the directory
cd Notebook
# Initialize Git
git init This command creates a hidden .git folder, the metadata store inside project directory that contains commit history, configuration, and references. It is the brain of your project.Adding Files to the Repository
Git does not automatically track files. You explicitly need to decide which files should be part of version control.
# Create a file
echo "Hello Hackers!" >> hello.txt
# Stage the file for commit
git add hello.txt
# Or stage all files in the directory
git add .
Staging prepares files for inclusion in the next commit, allowing selective tracking of changes.
Checking Repository Status
Use git status to inspect the current state of the working directory and staging area.
#Check repository status
git statusThis command reports:
- Which files are staged.
- Which files are modified but not staged.
- Which files are untracked.
Making Your First Commit
A commit is a snapshot of your project at a given point in time.
git commit -m "Initial commit: Added hello.txt"
Commits are immutable records, identified by unique SHA‑1 hashes. They form the backbone of Git’s Directed Acyclic Graph (DAG).
# View commit history:
git logThis displays the chronological sequence of commits, including author, timestamp, and commit message.
The Hackers Notebook
With just a few commands, you have:
- Initialized a repository.
- Added files to version control.
- Created your first commit.
This is the foundation of Git - a system that tracks your work step by step, ensuring progress is never lost. Every great project begins with a first commit, and yours has now been written into history. 🚀✨
