This project implements a distributed source control system in the style of Git. It is called zeet
. It provides core functionalities required for version control, such as initializing repositories, staging files, committing changes, and more. The tool is built to manage repositories on the local disk and is designed to be used as a CLI tool.
-
Initialize Repository: Create a repository in a directory, with the repository data stored in a
.zeet
subdirectory. -
Staging Files: Add files to the staging area. (
zeet add .
) -
Committing Changes: Commit staged files with messages.
-
Branching: Create and switch between branches.
-
Merging: Merge branches with parallel work into mainline. Fast-forward and 3-way merge are intelligently used to merge.
-
Conflicts marking: Conflicts are detected during merge and affected region in files are marked with symbols:
<<<<<<<
,=======
and>>>>>>>
.(conflicts require manual resolution) -
File Ignoring: Specify files to be ignored during commits in
.zeetignore
file. Will look for.gitignore
file if missing. -
Viewing Commit History: View the commit history with detailed information in a colorized output.
-
Diffs: View differences between commits and branches.
- Cloning Repositories: Clone a repository locally, copying the contents of the original repository to a new directory.
The project doesn't yet include advanced features like rebasing or conflict resolution beyond detection, but it covers the essential functionalities of version control systems like Git.
Zeet
is platform-agnostic because it leverages Node.js, allowing it to run on any system with Node.js installed.
You need to ensure you have node.js installed on your computer. The recommended version is at least version >=20.
Install globally on your computer:
npm install -g zeet
This will allow you to use the zeet
command in any repository.
Once installed, you can use it directly from the command line. Here are some example commands:
-
Initialize a repository:
zeet init
This creates a new repository in the current directory, storing the repository data in a
.zeet
subdirectory. -
Stage files:
zeet add <file1> <file2> ...
This stages the specified files, preparing them for commit.
Alternatively, you can use:zeet add .
-
View commit status:
zeet status
Shows files added to staging area and those that are not. Convenient to check files that will go into the next commit.
Sample output ofzeet status
-
Commit changes:
zeet commit -m "Commit message"
This commits the staged changes with the provided commit message.
-
View commit history:
zeet log
This displays the commit history, showing commit hashes, messages, and timestamps.
Sample output ofzeet log
-
Create branches:
zeet branch <branch-name>
This creates a new branch.
- Switch branches:
zeet switch <branch-name>
This switches to a created branch.
-
Merge branches:
zeet merge <branch-name>
This merges
<branch-name>
into the current checked out branch, with conflict detection.
Fast-forward merge strategy is used when history between the branches is linear. 3-way merge is used otherwise. -
View diffs:
zeet diff <commit-hash>
This shows the differences between working directory and the commit. In place of
<commit-hash>
, you can also specify branch or path to a file under repository.
Sample output ofzeet diff
Other than diffing with the working directory, you can also diff between 2 commits, branches or files. For example:
# Compare changes between commits zeet diff <commit-hash1> <commit-hash2> # Compare changes between branches zeet diff <stem> <feature-branch> # Compare differences of 'file1' in working directory with 'file1' in 'feature-branch' zeet diff <file1> <feature-branch> # Compare changes in files in workdir with the last recent commit zeet diff <file1> <file2>
-
Ignore files: Create a
.zeetignore
file in your repository root and list the files to be ignored.
It accepts the same patterns as with.gitignore
.
Note: To view more helpful information about a command, you can use
zeet <command-name> --help
Feel free to open issues or submit pull requests to contribute to the project. Contributions are welcome!
Distributed under the MIT License. See LICENSE
for more information.