Utilities â
Miscellaneous utility commands for working with repositories.
Init (hug init) â
Initialize a new Git or Mercurial repository. Defaults to Git.
Basic Usage â
# Initialize Git repo in current directory
hug init
# Initialize Git repo in new directory
hug init my-project
# Initialize with specific VCS
hug init --git
hug init --hg
# Skip post-init status display
hug init --no-status
# Pass options to underlying VCS
hug init --initial-branch=main
hug init my-project --bareFeatures â
Defaults to Git â
By default, hug init creates a Git repository. This makes it quick and easy to get started without specifying flags:
hug init my-new-projectForce Specific VCS â
Use --git or --hg to explicitly choose the version control system:
# Git (explicit)
hug init --git my-git-repo
# Mercurial
hug init --hg my-hg-repoPost-Init Status â
By default, Hug provides helpful information after initialization. For empty repositories, it shows a friendly message:
$ hug init my-repo
âšī¸ Info: Initializing Git repository...
â
Success: â Initialized Git repository in 'my-repo'.
âšī¸ Info: Empty repository. Create your first commit to see status.Use --no-status to skip this behavior, useful for scripts:
hug init --no-status my-repoSafety Features â
Prevents Re-initialization: Hug checks if a repository already exists and prevents accidental re-initialization:
$ hug init
â Error: Already a Git repository.Directory Creation: If the specified directory doesn't exist, Hug creates it for you:
hug init path/to/my-projectExamples â
Basic Git initialization:
hug initInitialize in new directory:
hug init my-awesome-project
cd my-awesome-projectInitialize with custom branch name:
hug init --initial-branch=main my-projectInitialize bare repository:
hug init --bare my-bare-repo.gitInitialize Mercurial repository:
hug init --hg my-hg-projectScript-friendly (no status output):
hug init --no-status project1
hug init --no-status project2Clone (hug clone) â
Clone a Git or Mercurial repository with automatic VCS detection.
Basic Usage â
# Auto-detect VCS from URL
hug clone https://github.com/user/repo.git
# Clone to specific directory
hug clone https://gitlab.com/user/repo.git my-project
# Force specific VCS
hug clone --git https://example.com/repo
hug clone --hg https://hg.example.com/repo
# Skip post-clone status display
hug clone --no-status https://github.com/user/repo.git
# Pass options to underlying VCS
hug clone https://github.com/user/repo.git --depth 1
hug clone https://github.com/user/repo.git --branch developFeatures â
Automatic VCS Detection â
Hug automatically detects whether a repository is Git or Mercurial based on URL patterns:
Git Detection:
- URLs ending with
.git - GitHub URLs (github.com)
- GitLab URLs (gitlab.com)
- Bitbucket Git URLs
- Gitea instances
- Codeberg URLs
Mercurial Detection:
- URLs ending with
.hg - URLs containing
hg.in the domain
If the VCS cannot be determined automatically, Hug will prompt you to choose.
Safety Features â
Directory Existence Check: If the target directory already exists, Hug will prompt for confirmation before overwriting:
$ hug clone https://github.com/user/repo.git existing-dir
Directory 'existing-dir' exists. Overwrite? (y/N)Cleanup on Failure: If a clone operation fails (e.g., network error, invalid repository), Hug automatically cleans up any partially cloned directory.
Post-Clone Status â
By default, Hug runs hug s after a successful clone to show you the repository status. This gives you immediate feedback about the cloned repository's state.
Use --no-status to skip this behavior, useful for scripts or when cloning multiple repositories:
hug clone --no-status https://github.com/user/repo1.git
hug clone --no-status https://github.com/user/repo2.gitExamples â
Clone from GitHub:
hug clone https://github.com/torvalds/linux.gitClone to specific directory:
hug clone https://github.com/rust-lang/rust.git rust-compilerShallow clone (faster for large repos):
hug clone https://github.com/kubernetes/kubernetes.git --depth 1Clone specific branch:
hug clone https://github.com/user/repo.git --branch developClone with SSH:
hug clone git@github.com:user/private-repo.gitForce Mercurial:
hug clone --hg https://hg.mozilla.org/mozilla-centralCommand Reference â
Usage: hug clone [--git|--hg] [--no-status] <url> [dir] [options]
Options:
--git Force Git as the VCS
--hg Force Mercurial as the VCS
--no-status Skip post-clone status display
Arguments:
<url> Repository URL to clone
[dir] Target directory (optional, defaults to repository name)
[options] Additional options passed to underlying VCSTips â
Working with Large Repositories
For large repositories, consider using --depth 1 to create a shallow clone:
hug clone https://github.com/large/repo.git --depth 1This downloads only the latest commit, significantly reducing clone time and disk space.
Script-Friendly Cloning
When writing scripts, use --no-status to avoid interactive output:
#!/bin/bash
for repo in repo1 repo2 repo3; do
hug clone --no-status "https://github.com/org/$repo.git"
doneAuthentication
Hug passes through authentication prompts from the underlying VCS. For automated workflows, configure SSH keys or credential helpers:
# Configure SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
# Add to GitHub/GitLab
# Or use credential helper
git config --global credential.helper storeOther Utilities â
Untrack (hug untrack) â
Stop tracking files but keep them locally. Useful for files that should be ignored but were already committed.
hug untrack config/secrets.ymlType and Dump â
Inspect Git objects directly:
# Show object type
hug type HEAD
hug type a1b2c3d
# Show object contents
hug dump HEAD
hug dump a1b2c3dWIP Management â
See Working Directory Commands for WIP (Work In Progress) branch management commands.