ββββββββββ βββββββ ββββ ββββββ βββ βββββββββββ ββββββββββββββ βββββββ ββββ βββ βββ βββ βββββββββ βββ βββββββ βββ βββ βββ βββββββββββββ βββββ ββββββββββββββββββββββββββββ ββββββ βββ βββββββββββββββ βββββββ βββ βββββ βββ
π οΈ A modern Git clone tool with a colorful CLI interface. β¨ Clony provides intuitive Git commands with clear output, smart file staging, and flexible repository management.
- π¨ Modern CLI interface with Rich for colorful, clear output
- π§ Git repo management with init and basic operations
- π Smart file staging preventing unchanged file commits
- π Flexible commit system with custom messages and authors
- π Multi-mode reset supporting soft, mixed, and hard resets
- πΏ Branch management with create, list, and delete operations
- 𧩠Modular architecture for easy extensibility
- π 100% test coverage ensuring reliability
- π Intuitive commands with consistent syntax
- π‘οΈ Clear error handling with actionable messages
- π Detailed logging for debugging operations
- π Transparent internals for educational purposes
- Python 3.10 or higher
- Git (for cloning the repository)
# Clone the repository
git clone https://github.com/DataRohit/clony.git
cd clony
# Set up virtual environment
python -m venv .venv
# Activate the virtual environment
# On Windows:
source .venv/Scripts/activate
# On Linux/Mac:
# source .venv/bin/activate
# Install the package in development mode
pip install -e .
# Verify installation
clony --version
If you plan to contribute to Clony, install the development dependencies:
pip install -e ".[dev]"
- Command not found: Ensure your virtual environment is activated and the package is installed
- Import errors: Make sure you've installed the package with
pip install -e .
- Permission issues: On Linux/Mac, you might need to make the run_checks.sh script executable with
chmod +x run_checks.sh
The following options are available for all commands:
--help, -h # Show help information for any command
--version, -v # Display version information
Display detailed help information about available commands and options.
# Show general help information with logo
clony help
# Show help for a specific command
clony init --help
Initialize a new Git repository in the specified directory.
# Basic Usage
clony init [path] # Create a new Git repository in the specified path (default: current directory)
# Options
--force, -f # Force reinitialization if repository already exists
--help, -h # Show help for init command
Examples:
# Initialize in current directory
$ clony init
[03/19/25 22:42:21] INFO Git repository initialized successfully
INFO Initialized empty Git repository in D:\Projects\test_repo
# Initialize in a specific directory that already exists
$ clony init my-project
[03/19/25 22:32:15] INFO Git repository initialized successfully
INFO Initialized empty Git repository in /path/to/my-project
# Initialize in a new directory (creates the directory automatically)
$ clony init new-project
[03/19/25 22:32:24] INFO Git repository initialized successfully
INFO Initialized empty Git repository in /path/to/new-project
# Try to initialize in existing repository
$ clony init existing-repo
[03/19/25 22:32:33] WARNING Git repository already exists
INFO Use --force to reinitialize
# Force reinitialization of an existing repository
$ clony init existing-repo --force
[03/19/25 22:32:42] INFO Git repository initialized successfully
INFO Initialized empty Git repository in /path/to/existing-repo
# Initialize with invalid path (non-existent parent directory)
$ clony init /invalid/path
[03/19/25 22:32:51] ERROR Parent directory does not exist: /invalid/path
# Initialize with relative path
$ clony init ../sibling-project
[03/19/25 22:33:00] INFO Git repository initialized successfully
INFO Initialized empty Git repository in /path/to/sibling-project
The init
command creates the standard Git directory structure including:
.git
directory with all required subdirectoriesobjects
directory for Git object storagerefs
directory withheads
andtags
subdirectories- Default
HEAD
file pointing to themain
branch - Basic Git configuration file
When initializing a repository, Clony performs several checks to ensure the operation will succeed:
- Verifies the parent directory exists
- Checks if a Git repository already exists at the location
- Creates all required directories and files with proper permissions
Stage a file by adding its content to the staging area. This command prepares a file to be included in the next commit by creating a blob object from the file content and updating the index.
The command will prevent staging files that haven't changed since the last commit, ensuring that only meaningful changes are committed. This check is performed regardless of whether the file is currently in the staging area or not, which means that even after a commit (which clears the staging area), you cannot stage a file that hasn't changed since that commit.
# Basic Usage
clony stage <file_path> # Stage a file for the next commit
# Options
--help, -h # Show help for stage command
Examples:
# Stage a file
$ clony stage test1.txt
[03/19/25 22:42:43] INFO File staged: 'test1.txt'
Staging Results
βββββββββββββ³βββββββββ³βββββββββββββββ
β File Path β Status β Content Hash β
β‘ββββββββββββββββββββββββββββββββββββ©
β test1.txt β STAGED β bb52363e β
βββββββββββββ΄βββββββββ΄βββββββββββββββ
# Try to stage a non-existent file
$ clony stage non_existent_file.txt
[03/19/25 22:35:20] ERROR File not found: 'non_existent_file.txt'
# Stage a file in a non-git repository
$ clony stage file_outside_repo.txt
[03/19/25 22:35:35] ERROR Not a git repository. Run 'clony init' to create one.
# Try to stage a file that's already staged with no changes
$ clony stage already_staged.txt
[03/19/25 22:35:45] WARNING File already staged: 'already_staged.txt'
Staging Results
βββββββββββββββββββ³ββββββββββββ³βββββββββββββββ
β File Path β Status β Content Hash β
β‘βββββββββββββββββββββββββββββββββββββββββββββ©
β already_staged.txtβ UNCHANGED β e5f6g7h8 β
ββββββββββββββββββββ΄ββββββββββββ΄βββββββββββββββ
# Stage a file after changing its content
$ echo "Changed content" > myfile.txt
$ clony stage myfile.txt
[03/19/25 22:36:05] INFO File staged: 'myfile.txt'
Staging Results
βββββββββββββ³βββββββββ³βββββββββββββββ
β File Path β Status β Content Hash β
β‘ββββββββββββββββββββββββββββββββββββ©
β myfile.txtβ STAGED β b2c3d4e5 β
βββββββββββββ΄βββββββββ΄βββββββββββββββ
# Try to stage a file with invalid path
$ clony stage /invalid/path/file.txt
[03/19/25 22:36:15] ERROR File not found: '/invalid/path/file.txt'
# Stage multiple files sequentially
$ clony stage file1.txt
[03/19/25 22:37:25] INFO File staged: 'file1.txt'
Staging Results
βββββββββββββ³βββββββββ³βββββββββββββββ
β File Path β Status β Content Hash β
β‘ββββββββββββββββββββββββββββββββββββ©
β file1.txt β STAGED β h8i9j0k1 β
βββββββββββββ΄βββββββββ΄βββββββββββββββ
$ clony stage file2.txt
[03/19/25 22:42:54] INFO File staged: 'file2.txt'
Staging Results
βββββββββββββ³βββββββββ³βββββββββββββββ
β File Path β Status β Content Hash β
β‘ββββββββββββββββββββββββββββββββββββ©
β file2.txt β STAGED β ac43975e β
βββββββββββββ΄βββββββββ΄βββββββββββββββ
The staging process performs several key operations:
- Calculates a SHA-1 hash of the file content
- Compresses the content using zlib
- Stores the compressed content in the Git object database
- Updates the index file with the file path and hash
- Prevents staging unchanged files to avoid empty commits
After staging, you can use the status
command to see all staged files, and then create a commit with the commit
command.
Create a new commit with the staged changes. This command creates a new commit object with the staged changes, including a tree object representing the directory structure and a reference to the parent commit.
The commit message is required, while author name and email are optional and will default to "Clony User" and "user@example.com" if not provided.
After a successful commit, the staging area is automatically cleared, ensuring a clean state for the next set of changes.
# Basic Usage
clony commit --message "Your commit message" # Create a commit with staged changes
# Options
--message, -m # The commit message (required)
--author-name # The name of the author (defaults to "Clony User")
--author-email # The email of the author (defaults to "user@example.com")
--help, -h # Show help for commit command
Examples:
# Create a basic commit
$ clony commit --message "Initial commit with test files"
Commit Information
βββββββββββββββ³ββββββββββββββββββββββββββββββββ³βββββββββββββββββββββββββββββββββ
β Commit Hash β Author β Message β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b68a0ef β Clony User β Initial commit with test files β
βββββββββββββββ΄ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββ
# Create a commit with author information
$ clony commit --message "Add feature" --author-name "John Doe" --author-email "john@example.com"
Commit Information
βββββββββββββββ³βββββββββββββββββββββββββββββ³ββββββββββββββ
β Commit Hash β Author β Message β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β e4f5g6h β John Doe <john@example.com>β Add feature β
βββββββββββββββ΄βββββββββββββββββββββββββββββ΄ββββββββββββββ
# Commit with a longer descriptive message
$ clony commit --message "Update test1.txt"
Commit Information
βββββββββββββββ³ββββββββββββββββββββββββββββββββ³βββββββββββββββββββ
β Commit Hash β Author β Message β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b6a6cba β Clony User β Update test1.txt β
βββββββββββββββ΄ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββ
# Try to commit without a message
$ clony commit
[03/19/25 22:38:35] ERROR Missing option '--message' / '-m'.
# Try to commit with no staged changes
$ clony commit --message "Empty commit"
[03/19/25 22:38:45] ERROR Nothing to commit. Run 'clony stage <file>' to stage changes.
# Try to commit outside a git repository
$ clony commit --message "Outside repo"
[03/19/25 22:38:55] ERROR Not a git repository. Run 'clony init' to create one.
The commit process performs several key operations:
- Creates a tree object representing the directory structure
- Gets the current HEAD commit as the parent
- Creates a commit object with the tree, parent, author info, and message
- Updates the branch reference to point to the new commit
- Updates the HEAD_TREE file to track all committed files
- Clears the staging area for the next set of changes
After creating a commit, you can use the log
command to view the commit history, and status
to confirm the staging area is cleared.
Show the working tree status. This command displays the state of the working directory and the staging area, showing which changes have been staged, which haven't, and which files aren't being tracked by Git.
The status command categorizes files into three main sections:
- Changes to be committed: Files that have been staged and are ready for the next commit
- Changes not staged for commit: Files that have been modified but not yet staged
- Untracked files: Files that are not tracked by Git
# Basic Usage
clony status [path] # Show the status of the working tree
# Options
--help, -h # Show help for status command
Examples:
# Show status with staged files
$ clony status
[03/19/25 22:42:49] INFO On branch main
INFO Use 'clony reset HEAD <file>...' to unstage
Changes to be committed
βββββββββββββ³βββββββββββ
β File β Status β
β‘βββββββββββββββββββββββ©
β test1.txt β New file β
βββββββββββββ΄βββββββββββ
INFO Use 'clony stage <file>...' to include in what will be committed
Untracked
files
βββββββββββββ
β File β
β‘ββββββββββββ©
β test2.txt β
βββββββββββββ
# Show status after committing all files (clean working tree)
$ clony status
[03/19/25 22:43:15] INFO On branch main
INFO Nothing to commit, working tree clean
# Show status after modifying a committed file
$ echo "Modified content" > test1.txt
$ clony status
[03/19/25 22:43:30] INFO On branch main
INFO Use 'clony stage <file>...' to update what will be committed
Changes not
staged for commit
βββββββββββββ³βββββββββββ
β File β Status β
β‘βββββββββββββββββββββββ©
β test1.txt β Modified β
βββββββββββββ΄βββββββββββ
# Show status in a non-git repository
$ clony status /not/a/repo
[03/19/25 22:43:45] ERROR Not a git repository. Run 'clony init' to create one.
The status command performs several operations:
- Checks if you're in a Git repository
- Determines the current branch
- Reads the index file to find staged changes
- Compares working directory files with the HEAD commit to find unstaged changes
- Identifies untracked files in the working directory
- Displays all findings in a clear, organized tabular format
Display the commit history. This command traverses the commit graph starting from HEAD and displays the commit history in reverse chronological order (most recent first).
For each commit, the following information is displayed:
- Commit Hash: The unique SHA-1 identifier of the commit
- Author: The name and email of the individual who made the commit
- Date: The exact date and time when the commit was made
- Commit Message: The message describing the changes introduced in the commit
# Basic Usage
clony log # Display the commit history
# Options
--help, -h # Show help for log command
Examples:
# Show commit history
$ clony log
Commit History
βββββββββββββββββββββββββββ³ββββββββββββββββββββββββββ³ββββββββββββββββββββββββββ³ββββββββββββββββββββββββββ
β Commit Hash β Author β Date β Message β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b6a6cbaf9e123456789abcβ¦ β Clony User β Wed Mar 19 22:45:00 β Update test1.txt β
β β <user@example.com> β 2025 +0530 β β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
β b68a0efae1cd79937eb746β¦ β Clony User β Wed Mar 19 22:43:00 β Initial commit with β
β β <user@example.com> β 2025 +0530 β test files β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
# Show commit history in a repository with no commits
$ clony log
[03/19/25 22:45:30] INFO No commits found.
# Show commit history outside a git repository
$ clony log
[03/19/25 22:45:45] ERROR Not a git repository. Run 'clony init' to create one.
The log command performs several operations:
- Reads the HEAD reference to find the current branch
- Traverses the commit graph from the most recent commit
- Parses each commit object to extract metadata (author, date, message)
- Formats the commit history in a clean tabular display
- Handles edge cases like empty repositories or detached HEAD states
Display all blob hashes from a specified commit. This command retrieves and displays all blob hashes associated with files in the specified commit's tree.
# Basic Usage
clony blobs <commit> # Display all blob hashes from the specified commit
# Options
--help, -h # Show help for blobs command
Examples:
# Show blobs from the main branch
$ clony blobs main
Blob Hashes in Commit b68a0efa
ββββββββββββββββββββββββββββββββββββββββββββ³ββββββββββββ
β Blob Hash β File Path β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β 9f4b6d8bfeaf44aaa69872286163784706d1b053 β test1.txt β
β ac439756c6fb3ee361bd0126ad6cdf9ffde9ec2c β test2.txt β
ββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββ
# Show blobs from a specific commit hash
$ clony blobs b6a6cbaf
Blob Hashes in Commit b6a6cbaf
ββββββββββββββββββββββββββββββββββββββββββββ³ββββββββββββ
β Blob Hash β File Path β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β f776a8f3bf069022eedc67803f8d40043fa56324 β test1.txt β
β ac439756c6fb3ee361bd0126ad6cdf9ffde9ec2c β test2.txt β
ββββββββββββββββββββββββββββββββββββββββββββ΄ββββββββββββ
# Try to get blobs from an invalid commit reference
$ clony blobs HEAD
[03/19/25 22:45:21] ERROR Invalid commit reference: HEAD
# Try to get blobs outside a git repository
$ clony blobs main
[03/19/25 22:46:15] ERROR Not a git repository. Run 'clony init' to create one.
The blobs command performs several operations:
- Resolves the commit reference (branch, tag, or commit hash)
- Reads the commit object to find the root tree
- Traverses the tree recursively to find all blob objects
- Displays the blob hashes and their associated file paths in a table
- Handles errors such as invalid commit references
Display the differences between two blob objects. This command compares the contents of two blob objects and shows the differences between them line by line.
# Basic Usage
clony diff <blob1> <blob2> # Compare two blob objects
# Options
--path1 TEXT # The path of the first file
--path2 TEXT # The path of the second file
--algorithm TEXT # The diff algorithm to use (myers or unified)
--context-lines INTEGER # The number of context lines to show in the unified diff
--help, -h # Show help for diff command
Examples:
# Compare two blob objects using their hashes
$ clony diff 9f4b6d8bfeaf44aaa69872286163784706d1b053 f776a8f3bf069022eedc67803f8d40043fa56324
- This is a test file
+ This is an updated test file
# Compare with paths and algorithm specified
$ clony diff 9f4b6d8bfeaf44aaa69872286163784706d1b053 f776a8f3bf069022eedc67803f8d40043fa56324 --path1 test1.txt --path2 test1.txt --algorithm unified
--- test1.txt
+++ test1.txt
@@ -1 +1 @@
-This is a test file
+This is an updated test file
# Try to use the diff command with only one blob hash
$ clony diff 9f4b6d8bfeaf44aaa69872286163784706d1b053
[03/19/25 22:47:15] ERROR Missing argument 'BLOB2'.
# Try to use diff outside a git repository
$ clony diff blob1 blob2
[03/19/25 22:47:30] ERROR Not a git repository. Run 'clony init' to create one.
The diff command performs several operations:
- Reads the content of both blob objects from the Git object database
- Parses the content of each blob
- Compares the content line by line using the specified algorithm
- Displays the differences in a clear, standardized format
- Handles various output formats based on the selected options
Reset the current HEAD to a specified commit. This command updates the HEAD to point to the specified commit, and optionally updates the index and working directory to match.
The reset command supports three modes:
- Soft Reset (--soft): Move HEAD to the specified commit without changing the index or working directory.
- Mixed Reset (--mixed): Move HEAD to the specified commit and update the index to match, but leave the working directory unchanged. This is the default mode.
- Hard Reset (--hard): Move HEAD to the specified commit and update both the index and working directory to match.
# Basic Usage
clony reset <commit> # Reset HEAD to the specified commit
# Options
--soft # Move HEAD without changing the index or working directory
--mixed # Move HEAD and update the index (default)
--hard # Move HEAD and update both the index and working directory
--help, -h # Show help for reset command
Examples:
# Perform a mixed reset (default)
$ clony reset b68a0efae1cd79937eb7466065db7fbd5dc4969a
Reset Results
βββββββββββββββ³βββββββββββββ³βββββββββββββββββββββββββββββ
β Commit Hash β Reset Mode β Actions Taken β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b68a0efa β MIXED β β’ HEAD pointer updated β
β β β β’ Index/staging area reset β
βββββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββββββββββ
Commit Details
βββββββββββββ³βββββββββββββββββββββββββββββββββββββββββββββββββ
β Property β Value β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Tree β 99f1d991447efa7c2455a7df54845d2b4b53e6dc β
β Parent β β
β Author β Clony User <user@example.com> 1742404380 +0530 β
β Committer β Clony User <user@example.com> 1742404380 +0530 β
β Message β Initial commit with test files β
βββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββ
# Perform a soft reset
$ clony reset --soft b68a0efa
Reset Results
βββββββββββββββ³βββββββββββββ³βββββββββββββββββββββββββ
β Commit Hash β Reset Mode β Actions Taken β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b68a0efa β SOFT β β’ HEAD pointer updated β
βββββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββββββ
Commit Details
βββββββββββββ³βββββββββββββββββββββββββββββββββββββββββββββββββ
β Property β Value β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Tree β 99f1d991447efa7c2455a7df54845d2b4b53e6dc β
β Parent β β
β Author β Clony User <user@example.com> 1742404380 +0530 β
β Committer β Clony User <user@example.com> 1742404380 +0530 β
β Message β Initial commit with test files β
βββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββ
# Perform a hard reset
$ clony reset --hard b68a0efa
Reset Results
βββββββββββββββ³βββββββββββββ³βββββββββββββββββββββββββββββββββ
β Commit Hash β Reset Mode β Actions Taken β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b68a0efa β HARD β β’ HEAD pointer updated β
β β β β’ Index/staging area reset β
β β β β’ Working directory updated β
βββββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββββββββββββββ
Commit Details
βββββββββββββ³βββββββββββββββββββββββββββββββββββββββββββββββββ
β Property β Value β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Tree β 99f1d991447efa7c2455a7df54845d2b4b53e6dc β
β Parent β β
β Author β Clony User <user@example.com> 1742404380 +0530 β
β Committer β Clony User <user@example.com> 1742404380 +0530 β
β Message β Initial commit with test files β
βββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββ
# Reset to a branch name
$ clony reset main
Reset Results
βββββββββββββββ³βββββββββββββ³βββββββββββββββββββββββββββββ
β Commit Hash β Reset Mode β Actions Taken β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β b6a6cba β MIXED β β’ HEAD pointer updated β
β β β β’ Index/staging area reset β
βββββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββββββββββ
Commit Details
βββββββββββββ³βββββββββββββββββββββββββββββββββββββββββββββββββ
β Property β Value β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Tree β 2a51f3ebb69151c2a11aad6709dc448ef9e8c66b β
β Parent β b68a0efae1cd79937eb7466065db7fbd5dc4969a β
β Author β Clony User <user@example.com> 1742404420 +0530 β
β Committer β Clony User <user@example.com> 1742404420 +0530 β
β Message β Update test1.txt β
βββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββ
# Try to reset with an invalid commit reference
$ clony reset invalid-commit
[03/19/25 22:49:15] ERROR Failed to reset HEAD to invalid-commit: Not a valid commit reference
# Try to reset outside a git repository
$ clony reset b68a0efa
[03/19/25 22:49:30] ERROR Not in a Git repository
The reset command performs several operations depending on the mode:
- Resolves the commit reference to a specific commit hash
- Updates the HEAD reference to point to the new commit
- In mixed and hard modes, updates the index to match the commit's tree
- In hard mode, updates the working directory to match the commit's tree
- Provides detailed output about the actions taken during the reset
- Shows information about the commit you've reset to
- Handles errors such as invalid commit references or repository issues
Create a new branch in the repository. This command creates a new branch pointing to the specified commit or the current HEAD if no commit is specified.
# Basic Usage
clony branch <branch_name> # Create a new branch pointing to HEAD
clony branch <branch_name> --commit <commit_hash> # Create a branch pointing to a specific commit
clony branch <branch_name> --delete # Delete a branch
clony branch <branch_name> --delete --force # Force delete a branch
clony branch --list # List all branches in the repository
# Options
--commit TEXT # The commit hash to point the branch to (default: HEAD)
--delete, -d # Delete the specified branch
--force, -f # Force operation (such as deleting current branch)
--list, -l # List all branches in the repository
--help, -h # Show help for branch command
Examples:
# Create a new branch pointing to HEAD
$ clony branch feature-branch
[03/20/25 18:26:32] INFO Created branch 'feature-branch' pointing to
1cf1a49fed25e8cd86109dd61e009c9ab5c4f510
# Create a branch pointing to a specific commit
$ clony branch old-branch --commit b68a0efa
[03/20/25 18:26:35] INFO Created branch 'old-branch' pointing to
b68a0efae1cd79937eb7466065db7fbd5dc4969a
# Try to create a branch with invalid commit
$ clony branch invalid-branch --commit invalid-hash
[03/20/25 18:26:38] ERROR Invalid commit reference: invalid-hash
# Delete a branch
$ clony branch feature-branch --delete
[03/20/25 18:27:06] INFO Deleted branch: feature-branch
# Try to delete the current branch
$ clony branch main --delete
[03/20/25 18:27:02] ERROR Cannot delete the current branch: main
# Force delete the current branch
$ clony branch main --delete --force
[03/20/25 18:27:10] INFO Force deleted current branch: main
# List all branches
$ clony branch --list
Branches
βββββββββββ³βββββββββββββββββ
β Current β Branch β
β‘βββββββββββββββββββββββββββ©
β β feature-branch β
β β β main β
βββββββββββ΄βββββββββββββββββ
Checkout a branch, commit, or restore files. This command has two main functionalities:
- Branch/Commit Checkout: Updates the HEAD, index, and working directory to match the state of the specified branch or commit.
- File Restoration: Restores specific files from a branch or commit without changing the current branch.
# Basic Usage
clony checkout <target> # Checkout a branch or commit
clony checkout <target> <file_paths>... # Restore specific files from a branch or commit
# Options
--force, -f # Force checkout even if there are uncommitted changes
--help, -h # Show help for checkout command
Examples:
# Checkout a branch
$ clony checkout feature-branch
Checking out feature-branch
Checkout Results
ββββββββββββββββββ³βββββββββ³βββββββββββββ³ββββββββββββββββ
β Target β Type β HEAD State β Files Updated β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β feature-branch β Branch β Attached β 3 β
ββββββββββββββββββ΄βββββββββ΄βββββββββββββ΄ββββββββββββββββ
# Checkout a commit (detached HEAD)
$ clony checkout d2c4431
Checking out d2c4431
Checkout Results
βββββββββββ³βββββββββ³βββββββββββββ³ββββββββββββββββ
β Target β Type β HEAD State β Files Updated β
β‘ββββββββββββββββββββββββββββββββββββββββββββββββ©
β d2c4431 β Commit β Detached β 3 β
βββββββββββ΄βββββββββ΄βββββββββββββ΄ββββββββββββββββ
# Checkout will fail if there are uncommitted changes
$ clony checkout main
Checking out main
Checkout Conflicts
βββββββββββββ³βββββββββββ³ββββββββββββββββββββββββββ
β File β Status β Action Required β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββ©
β file1.txt β Modified β Commit or stash changes β
βββββββββββββ΄βββββββββββ΄ββββββββββββββββββββββββββ
Checkout failed.
# Force checkout to overwrite uncommitted changes
$ clony checkout main --force
Checking out main
Checkout Results
ββββββββββ³βββββββββ³βββββββββββββ³ββββββββββββββββ
β Target β Type β HEAD State β Files Updated β
β‘βββββββββββββββββββββββββββββββββββββββββββββββ©
β main β Branch β Attached β 3 β
ββββββββββ΄βββββββββ΄βββββββββββββ΄ββββββββββββββββ
# Restore a specific file from a commit
$ clony checkout 9efa21c file1.txt
Restoring file 'file1.txt' from 9efa21c
Restored 1 file(s) from 9efa21c
# Restore will fail if there are local modifications
$ clony checkout 9efa21c file1.txt
Restoring file 'file1.txt' from 9efa21c
Checkout Conflicts
βββββββββββββ³βββββββββββ³ββββββββββββββββββββββββββ
β File β Status β Action Required β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββ©
β file1.txt β Modified β Commit or stash changes β
βββββββββββββ΄βββββββββββ΄ββββββββββββββββββββββββββ
Failed to restore files.
# Force restore to overwrite local modifications
$ clony checkout 9efa21c file1.txt --force
Restoring file 'file1.txt' from 9efa21c
Restored 1 file(s) from 9efa21c
The checkout command performs several key operations:
-
For branch/commit checkout:
- Updates HEAD to point to the branch or commit
- Updates the index (staging area) to match the tree
- Updates the working directory files
- Provides a warning when entering a detached HEAD state
-
For file restoration:
- Extracts the specified files from the target commit/branch
- Updates only those files in the working directory
- Preserves the current branch and HEAD state
- Detects conflicts with local modifications
The --force
flag overrides conflict detection and allows the command to proceed even when uncommitted changes would be lost. Use this option with caution as it can lead to data loss.
Perform a three-way merge with the current branch. This command merges changes from a specified commit into the current branch, using an explicitly provided base commit as the common ancestor.
Unlike standard Git which automatically finds the common ancestor, Clony requires you to manually specify both the base commit and the commit to be merged.
# Basic Usage
clony merge <base> <other> # Merge changes from OTHER into current branch, with BASE as common ancestor
# Options
--help, -h # Show help for merge command
Examples:
# Merge a feature branch into the current branch
$ clony merge 9dccc5d fc16929
[03/24/25 16:38:12] INFO Merge completed successfully with no conflicts.
# Merge with conflicts
$ clony merge base_commit feature_branch
[03/24/25 16:39:15] WARNING Merge completed with 2 conflict(s). Manual resolution required.
Merge Results
βββββββββββββ³βββββββββββ³βββββββββββββ
β File β Status β Conflicts β
β‘ββββββββββββββββββββββββββββββββββββ©
β test1.txt β Conflictsβ 1 β
β test2.txt β Conflictsβ 1 β
βββββββββββββ΄βββββββββββ΄βββββββββββββ
Conflicts were found during the merge:
File: test1.txt
ββββββββ³ββββββββββββββββ³βββββββββββββββββββββββ
β Line β This Branch β Other Branch β
β‘ββββββββββββββββββββββββββββββββββββββββββββββ©
β 3 β This line β Different line β
ββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ
# Try to merge with invalid base commit
$ clony merge invalid_base feature_branch
[03/24/25 16:40:30] ERROR Invalid base commit: invalid_base
# Try to merge with invalid other commit
$ clony merge base_commit invalid_other
[03/24/25 16:40:45] ERROR Invalid other commit: invalid_other
# Try to merge outside a git repository
$ clony merge base_commit other_commit
[03/24/25 16:41:00] ERROR Not a git repository. Run 'clony init' to create one.
The merge command performs several key operations:
- Validates both the base and other commit references
- Identifies the current branch's HEAD commit
- Performs a three-way merge between base, HEAD, and other commits
- Detects conflicts when the same lines are modified differently
- Displays merge results in a clean, formatted table
- Shows detailed conflict information when conflicts are found
The key difference from standard Git is that Clony requires you to explicitly specify the base commit (common ancestor), while Git automatically computes this. This gives you more control but requires more knowledge of your repository's commit history.
Clony is built with a focus on code quality, test coverage, and maintainability. The project follows a modular architecture that makes it easy to extend and enhance.
The codebase is organized into several key modules:
-
Core: Contains the fundamental Git data structures and operations
objects.py
: Implements Git objects (blobs, trees, commits)refs.py
: Handles Git references (branches, tags)repository.py
: Manages Git repositories
-
Internals: Provides internal utilities for Git operations
commit.py
: Handles commit creation and managementlog.py
: Manages the commit history functionalityreset.py
: Implements reset functionality with different modesstaging.py
: Manages the staging area and file stagingstatus.py
: Manages the working tree status functionalitybranch.py
: Handles branch creation, listing, and deletion
-
Utils: Contains utility functions and helpers
logger.py
: Configures logging throughout the application
-
CLI: The command-line interface (
cli.py
) that ties everything together
# Clone the repository
git clone https://github.com/DataRohit/clony.git
cd clony
# Set up virtual environment
python -m venv .venv
source .venv/Scripts/activate # Windows
# source .venv/bin/activate # Linux/Mac
# Install development dependencies
pip install -e ".[dev]"
Clony uses several tools to maintain code quality:
# Run tests with coverage
pytest -v
# Run linting
ruff check .
# Format code
ruff format .
For convenience, a script is provided to run both linting and tests in one command:
# Make the script executable (first time only)
chmod +x run_checks.sh
# Run linting and tests
./run_checks.sh
This script will:
- Run Ruff checks on your code
- Attempt to fix any issues automatically
- Run pytest with coverage reporting
It's recommended to run this script after making changes to ensure code quality and test coverage are maintained.
Contributions to Clony are welcome! Here are some guidelines to follow:
- Fork the repository and create a new branch for your feature or bug fix
- Write tests for your changes to maintain 100% test coverage
- Follow the code style by running the formatting tools before submitting
- Run the automated checks to ensure your changes pass all tests
- Submit a pull request with a clear description of your changes
- Modularity: Each component has a single responsibility
- Testability: All code is designed to be easily testable
- Error Handling: Robust error handling with informative messages
- Documentation: Clear documentation for all functions and modules
- User Experience: Focus on providing a clean and intuitive CLI
This project is licensed under the MIT License - see the LICENSE file for details.