๐ ๏ธ 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.
Project description
Clony
โโโโโโโโโโ โโโโโโโ โโโโ โโโโโโ โโโ
โโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโ โโโโ
โโโ โโโ โโโ โโโโโโโโโ โโโ โโโโโโโ
โโโ โโโ โโโ โโโโโโโโโโโโโ โโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโ
โโโโโโโโโโโโโโโ โโโโโโโ โโโ โโโโโ โโโ
๐ ๏ธ 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.
โจ Features
- ๐จ 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
๐ Table of Contents
๐ง Installation
Prerequisites
- Python 3.10 or higher
- Git (for cloning the repository)
Installation Steps
# 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
Installing for Development
If you plan to contribute to Clony, install the development dependencies:
pip install -e ".[dev]"
Troubleshooting
- 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
๐ Usage
Available Commands
Global Options
The following options are available for all commands:
--help, -h # Show help information for any command
--version, -v # Display version information
help
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
init
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:
.gitdirectory with all required subdirectoriesobjectsdirectory for Git object storagerefsdirectory withheadsandtagssubdirectories- Default
HEADfile pointing to themainbranch - 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
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.
commit
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.
status
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
log
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
blobs
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
diff
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
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
branch
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
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.
merge
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.
๐ป Development
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.
Architecture Overview
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
Development Environment Setup
# 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]"
Code Quality Tools
Clony uses several tools to maintain code quality:
# Run tests with coverage
pytest -v
# Run linting
ruff check .
# Format code
ruff format .
Automated Checks
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.
Contribution Guidelines
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
Key Design Principles
- 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
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clony-0.1.12.tar.gz.
File metadata
- Download URL: clony-0.1.12.tar.gz
- Upload date:
- Size: 117.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6301e6815bbf62be1bc89966569881daf43dab3761ba32ff371a6a07778646d5
|
|
| MD5 |
3bb5c8677ac9915ebb5c65fbb7a5017b
|
|
| BLAKE2b-256 |
b1bc8db57ffa0ddad929fa039260fd1f0f724785c6e25b7d2dadcff85c1344df
|
Provenance
The following attestation bundles were made for clony-0.1.12.tar.gz:
Publisher:
publish.yml on DataRohit/Clony
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clony-0.1.12.tar.gz -
Subject digest:
6301e6815bbf62be1bc89966569881daf43dab3761ba32ff371a6a07778646d5 - Sigstore transparency entry: 187132197
- Sigstore integration time:
-
Permalink:
DataRohit/Clony@f1120f66af757304aa15dd7b290ca2b7d3ebed4b -
Branch / Tag:
refs/tags/v0.1.12 - Owner: https://github.com/DataRohit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1120f66af757304aa15dd7b290ca2b7d3ebed4b -
Trigger Event:
release
-
Statement type:
File details
Details for the file clony-0.1.12-py3-none-any.whl.
File metadata
- Download URL: clony-0.1.12-py3-none-any.whl
- Upload date:
- Size: 54.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f74649f0457140fe5c120aa11a07746dd28985460b20d438c85a9c0edd0f33f
|
|
| MD5 |
bad1e0c4ee84687ff171e16b89137485
|
|
| BLAKE2b-256 |
19bcbf8feb1c329ddf6b597833df110a5c69c1c13a098d90c5e43db1d2be8f7e
|
Provenance
The following attestation bundles were made for clony-0.1.12-py3-none-any.whl:
Publisher:
publish.yml on DataRohit/Clony
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clony-0.1.12-py3-none-any.whl -
Subject digest:
6f74649f0457140fe5c120aa11a07746dd28985460b20d438c85a9c0edd0f33f - Sigstore transparency entry: 187132199
- Sigstore integration time:
-
Permalink:
DataRohit/Clony@f1120f66af757304aa15dd7b290ca2b7d3ebed4b -
Branch / Tag:
refs/tags/v0.1.12 - Owner: https://github.com/DataRohit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f1120f66af757304aa15dd7b290ca2b7d3ebed4b -
Trigger Event:
release
-
Statement type: