histree-vcs
v1.0.2
Published
Version Control System, liteweight
Readme
HisTree 🌳
HisTree is a lightweight, Git-like version control system implemented in Node.js. It provides essential version control functionalities such as initializing repositories, adding files, committing changes, managing branches, and viewing commit histories—all through a simple command-line interface (CLI).
Table of Contents
Features
- 🗂 Initialize Repository: Set up a new HisTree repository.
- ➕ Add Files: Stage files for committing.
- 💾 Commit Changes: Save snapshots of your project with commit messages.
- 🕮 View Commit Log: Browse through the history of commits.
- 🔍 Show Commit Diff: View differences between commits.
- 🌿 Branch Management: Create and list branches.
- 🔄 Checkout: Switch between branches or specific commits.
- 🔀 Merge Branches: Combine changes from different branches.
- 🔧 Reset Repository: Undo commits with soft or hard reset options.
- 📊 Check Status: Display the current state of the working directory and staging area.
Prerequisites
Before installing HisTree, ensure you have the following installed on your system:
- Node.js (v14 or later)
- npm (Node Package Manager) or yarn
You can download Node.js from the official website.
Installation
You can install HisTree globally using npm or yarn:
Using npm
npm install -g histreeUsing yarn
yarn global add histreeNote: You might need administrative privileges to install packages globally. Use
sudoif necessary.
Usage
After installation, you can use the histree command in your terminal. Below are the available commands and their descriptions.
Initialize Repository
Set up a new HisTree repository in the current directory.
histree initAdd Files
Stage specific files for the next commit.
histree add <file>Example:
histree add index.jsCommit Changes
Commit staged files with a descriptive message.
histree commit <message>Example:
histree commit "Initial commit with project structure"View Commit Log
Display the history of commits in the repository.
histree logShow Commit Diff
View the differences introduced in a specific commit.
histree show <commitHash>Example:
histree show a1b2c3dBranch Management
Create a New Branch
Create a new branch with the specified name.
histree branch <branchName>Example:
histree branch feature-loginList All Branches
List all existing branches in the repository.
histree branchesCheckout
Switch to a different branch or a specific commit.
histree checkout <target>Example:
histree checkout feature-loginMerge Branches
Merge a specified branch into the current branch.
histree merge <branchName>Example:
histree merge feature-loginNote: The current implementation includes a placeholder for merge logic. Handling conflicts and advanced merge scenarios may require further development.
Reset Repository
Reset the repository to a specific commit with optional modes.
histree reset <commitHash> [mode]modecan be eithersoftorhard.- Soft Reset: Moves
HEADto the specified commit without altering the working directory or staging area. - Hard Reset: Moves
HEADand updates the working directory and staging area to match the specified commit.
- Soft Reset: Moves
Examples:
histree reset a1b2c3d
histree reset a1b2c3d hardCheck Status
Display the current status of the working directory and staging area.
histree statusExamples
Here are some common workflows using HisTree:
Initialize a New Repository
mkdir my-project cd my-project histree initAdd and Commit Files
touch index.js histree add index.js histree commit "Add index.js with basic setup"Create and Switch to a New Branch
histree branch feature-auth histree checkout feature-authMerge Branches
histree checkout main histree merge feature-authView Commit History
histree logCheck Repository Status
histree status
Contributing
Contributions are welcome! If you'd like to contribute to HisTree, please follow these steps:
Fork the Repository
Click the "Fork" button at the top of this page to create your own fork of the repository.
Clone Your Fork
git clone https://github.com/your-username/histree.git cd histreeInstall Dependencies
npm installCreate a New Branch
git checkout -b feature/your-feature-nameMake Your Changes
Implement your feature or bug fix.
Commit Your Changes
git commit -m "Add feature: your feature description"Push to Your Fork
git push origin feature/your-feature-nameCreate a Pull Request
Go to the original repository and click "New Pull Request" to submit your changes for review.
License
This project is licensed under the MIT License.
Acknowledgements
- Commander.js - CLI framework used for command parsing.
- Chalk - Terminal string styling.
- diff - Library for comparing differences between texts.
Feel free to customize this README further to better fit your project's specifics and any additional features or instructions you may have!
