dev-resources.site
for different kinds of informations.
I built Zeet. A Git-like version Control System
π Source Code
You can find the source code for Zeet on GitHub.
π¬ DEMO
Motivation
Some time back, my curiosity about the inner workings of Git led me on an exciting journey. I sifted through various resources(though not Gitβs source code) to understand how Git works. Inspired, I wrote an article summarizing my findings. What stook with me from git-scm book:
The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.
Conceptually, most other systems store information as a list of file-based changes.
Git doesnβt think of or store its data this way. Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem.
That insight stayed with me, but I didn't do much with itβuntil I stumbled upon a challenge to build a Version Control System (VCS). I embraced it eagerly, seeing it as an opportunity to transform my theoretical knowledge into a tangible project. And so, I worked on Zeetβa lightweight, Git-inspired VCS built with Node.js.
How Zeet Works
Much like Git, Zeet manages repository versions as snapshots. It uses a .zeet
directory to store all its data locally, but unlike Git, the snapshots are not compressed.
The process involves three main areas:
- Working Directory: Where you edit files.
- Staging Area: Files added here are prepared for commits.
- Local Database: Stores snapshots of committed changes.
Zeet captures the essence of Git while offering simplicity for educational and hobbyist purposes.
Features of Zeet
π οΈ What Zeet Can Do
-
Repository Initialization: Create a Zeet repository with a
.zeet
subdirectory. - Staging Files: Add files to the staging area before committing.
- Committing Changes: Save staged files to the local database with descriptive messages.
- Branching: Work on parallel branches and switch between them effortlessly.
- Merging: Merge branches intelligently using fast-forward or 3-way merges.
-
Conflict Detection and Resolution: Detect conflicts during merges, mark them with symbols (
<<<<<<<
,=======
,>>>>>>>
), and resolve them manually. -
File Ignoring: Specify files to ignore using
.zeetignore
or.gitignore
. - Commit History: View detailed and colorized logs of commit histories.
- Diffs: Compare changes between commits, branches, or files.
π What Zeet Cannot Do (Yet)
- Show the repository status beyond staged, untracked, or deleted files.
- Clone remote repositories.
- Perform rebase merges.
How to use Zeet
Install Zeet globally via npm:
`npm i -g zeet`
Requirements:
- Node.js v20+
- A basic understanding of CLI tools
Core Commands
-
See usage
zeet --help
-
Initialize Repository
zeet init
-
Stage Files
zeet add <file1> <file2> ...
To stage all files:
zeet add .
-
Commit changes
zeet commit -m "Your Commit message"
-
View commit history
zeet log
-
Branch Management:
-
Create a branch:
zeet branch <branch-name>
-
Switch branches:
zeet switch <branch-name>
-
-
Merge branches
zeet merge <branch-name>
Merge conflicts will be detected and marked for manual resolution.
-
View diffs
zeet diff <commit-hash>
Compares two commits:
zeet diff <commit-hash1> <commit-hash2>
In place of
<commit-hash>
, you can alternatively specify branch or path to a file under repository.
Final toughts
Zeet is a hobby project that distills the essence of Git into a minimal yet functional version control system. While itβs not as robust as Git, it showcases the core principles of version control, making it a great tool for learning and experimenting.
Want to contribute? Head over to the Zeet repository on GitHub.
We could make Zeet even better.
Featured ones: