DEV Community

Cover image for I built Zeet. A Git-like version Control System
Smitter
Smitter

Posted on

1

I built Zeet. A Git-like version Control System

🚀 Source Code

You can find the source code for Zeet on GitHub.

🎬 DEMO

zeet demo in asciicast

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

  1. Repository Initialization: Create a Zeet repository with a .zeet subdirectory.
  2. Staging Files: Add files to the staging area before committing.
  3. Committing Changes: Save staged files to the local database with descriptive messages.
  4. Branching: Work on parallel branches and switch between them effortlessly.
  5. Merging: Merge branches intelligently using fast-forward or 3-way merges.
  6. Conflict Detection and Resolution: Detect conflicts during merges, mark them with symbols (<<<<<<<, =======, >>>>>>>), and resolve them manually.
  7. File Ignoring: Specify files to ignore using .zeetignore or .gitignore.
  8. Commit History: View detailed and colorized logs of commit histories.
  9. 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`
Enter fullscreen mode Exit fullscreen mode

Requirements:

  • Node.js v20+
  • A basic understanding of CLI tools

Core Commands

  1. See usage

    zeet --help
    
  2. Initialize Repository

    zeet init
    
  3. Stage Files

    zeet add <file1> <file2> ...
    

    To stage all files:

    zeet add .
    
  4. Commit changes

    zeet commit -m "Your Commit message"
    
  5. View commit history

    zeet log
    
  6. Branch Management:

    1. Create a branch:

      zeet branch <branch-name>
      
    2. Switch branches:

      zeet switch <branch-name>
      
  7. Merge branches

    zeet merge <branch-name>
    

    Merge conflicts will be detected and marked for manual resolution.

  8. 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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs