Most developers use git every day without really knowing what happens inside the .git folder.
I built CommitHub to explore and understand the internal mechanics behind version control systems such as snapshots, staging areas, and branching logic.
CommitHub is a lightweight CLI-based version control tool that recreates some of the core functionality of Git.
It also includes a remote synchronization feature using AWS S3, allowing commits to be pushed and pulled similar to a remote repository.
- The Challenge: How can a system track file changes across time without storing unnecessary duplicate data?
- The Idea: Build a simplified version control system from scratch and understand how commits, branches, and repository history are managed internally.
- The Approach: Implement a snapshot-based architecture where each commit represents the state of the project at a given moment.
- Remote Storage: Integrate AWS S3 to simulate a remote repository similar to how Git interacts with services like GitHub.
The core logic revolves around the hidden .CommitHub directory, which manages the repository state.
-
Staging Area
Files are first added to a temporary index before being included in the next commit. -
Commit Objects
Each commit stores metadata (message, timestamp, etc.) along with the snapshot of tracked files. -
Branching Model
Branches work as pointers to commit IDs. Switching branches updates theHEADpointer and restores the working directory to that commit's state.
Prerequisites
Node.js (v16 or higher)
AWS credentials configured (for remote features)
git clone https://github.com/your-username/commithub.git
cd commithub
npm install
# Initialize a repository
node index.js init
# Stage a file
node index.js add file.txt
# Create a commit
node index.js commit -m "Fixed the login logic"
# Create a branch
node index.js branch feature-ui
# Switch to that branch
node index.js checkout feature-ui
Remote Sync (AWS S3)
CommitHub uses the AWS SDK to treat an S3 bucket as a remote repository. Push Uploads the local .CommitHub state to the configured S3 bucket. Pull Downloads the remote state and updates the local repository accordingly. This simulates a simplified GitHub-style push and pull workflow.
Tech Stack Runtime: Node.js
CLI Framework: yargs
Cloud Storage: AWS S3
Core Logic: Node.js fs module for repository state management