Getting Started with Hug SCM β
Welcome to Hug SCM! This guide will take you from complete beginner to comfortable user, teaching you the essentials of version control with Hug's humane interface.
Why Hug? β
Hug SCM provides four layers of value over raw Git:
1. Humanization - Better UX for Git β
- Brevity Hierarchy: Shorter = safer (
hug astages tracked only;hug aastages everything) - Memorable Commands:
hug back 1vsgit reset --soft HEAD~1 - Progressive Destructiveness:
discard < wipe < purge < zap < rewind - Semantic Prefixes: Commands grouped by purpose (
h*= HEAD,w*= working dir, etc.) - Built-in Safety: Auto-backups, confirmations, dry-run on destructive operations
- Clear Feedback: Informative messages with β success, β οΈ warnings, colored output
2. Workflow Automation β
- Combined Operations:
--with-files= log + file listing in one command - Temporal Queries:
-t "3 days ago"instead of date math - Smart Defaults: Sensible scoping, interactive file selection
- Interactive Modes: Gum-based selection with
--or-i
3. Computational Analysis β (Impossible with Pure Git) β
- Co-change Detection: Statistical correlation analysis of files that change together
- Ownership Calculation: Recency-weighted expertise detection (who knows this code)
- Dependency Graphs: Graph traversal to find related commits via file overlap
- Activity Patterns: Temporal histograms showing when/how team works
- Churn Analysis: Line-level change frequency to identify code hotspots
These features require Python-based data processing, graph algorithms, and statistical analysisβbeyond what Git's plumbing commands can provide.
4. Machine-Readable Data Export π€ β
- JSON Output:
--jsonflag on analyze, stats, and churn commands - Automation Ready: Build dashboards, integrate with CI/CD, create custom reports
- Structured Data: All computational analysis exports to JSON for external tools
Core Concepts: Your Programming Laboratory β
To make Git's abstract concepts more concrete, let's think of your repository as a high-tech lab facility. Hug provides a humane layer over Git's core components.
The Three Areas of Your Lab β
Git manages your code across three main areas. Hug's commands give you clear visibility and control over each one.
1. Working Directory - Your Lab Table β
These are the actual files on your filesystem.
Lab Analogy
Think of your working directory as the main lab table in your current lab room. It's where you have all your files laid out in front of you.
You can edit them, add new ones, and delete old ones freely. This is your live, hands-on workspace. Any changes you make here are "live," but they haven't been officially recorded by Hug's security cameras yet.
Hug's View:
hug su(Status + Unstaged) shows you the "mess" on your lab tablehug w discardcleans it up
2. The Index (Staging Area) - Your Preparation Counter β
A "holding area" where you prepare your next official record, known as a commit.
Lab Analogy
This is your lab's preparation counter. After completing an experiment on your lab table, you move the results (your changed files) here to be documented and stored.
Hug's View:
hug a(Add) andhug aa(Add All) move files from the lab table to the preparation counterhug ss(Status + Staged) shows you exactly what's on the counterhug usmoves things back to the lab table
3. The Repository (Commits & HEAD) - Your Security Recording β
The permanent history of your project, made up of commits.
Lab Analogy
A commit is like a labeled moment in your lab's security camera recording. It's a permanent snapshot of your staged files at a specific point in time. HEAD is simply a pointer to the most recent recording you've made on your current timeline.
Hug's View:
hug c(Commit) takes everything on the preparation counter and creates that permanent snapshothug llets you review the timeline of all your recordingshug h backandhug h undomove the HEAD pointer back to an earlier recording
Branches: Your Lab Rooms β
As your project grows, you might want to work on a new feature without disturbing the stable, working version of your code.
Lab Analogy
A branch is like having a separate lab room within your main facility. You can experiment with new ideas in this room without affecting the main project. If your experiment is successful, you can merge your findings back into the main room. If not, you can simply close off the room.
Hug's View:
hug bc new-feature: Creates a new lab room callednew-featureand immediately moves you into ithug b main: Moves you out of your current room and back into themainlab room- The files on your "lab table" (working directory) instantly swap to match the state of the new room you've entered
The WIP Workflow: A Better Way to Park Work β
Other version control systems have a more convoluted "stash" feature that is a single, temporary holding area local to your machine. It can be lost if something happens to your computer.
Hug promotes the WIP (Work-In-Progress) workflow as a safer, more robust alternative.
What is it? Instead of a stash, hug wip (Work In Progress) creates a real, timestamped branch (WIP/YY-MM-DD/HHmm.slug). It commits all your current changes (staged, unstaged, and untracked) to this branch.
Why is it better?
- Persistent & Safe: A WIP branch is part of your repository's history. It won't get lost if you rebase or switch machines.
- Shareable: You can push a WIP branch (
hug bpush) to a remote repository to back it up or get feedback from a teammate. - Versioned: You can continue to work on a WIP branch, adding more commits to document your experiment or spike.
- Clear:
hug bl(Branch List) gives you a clear, descriptive list of all your parked tasks, unlike the cryptic lists from other tools.
The wip / wips / unwip / wipdel commands provide a complete, safe lifecycle for managing temporary work, making it one of Hug's cornerstone features.
Your First Workflow β
This is the simple, repeatable process you'll use every day to save your work.
Step 1: Create Your Lab Facility (hug init) β
You have a new project idea, which means you need a place to work. In our analogy, hug init (Initialize) gives you a big, empty laboratory facility for your project.
The hug init command initializes a new Git repository in your project folder. A repository (or "repo") is essentially your project's dedicated lab facility (with multiple lab rooms), containing all your files and the entire history of their changes.
To create your lab facility, navigate to your project's folder in the terminal and type:
hug initThis creates a hidden .git folder, which is the "control center" of your facility where all the history is stored.
Step 2: Do Your Work (The Lab Table) β
Now that you have your lab facility, where do you actually do the work? The folder on your computer where your project files are located is your working directory.
Think of your working directory as the main lab table in your current lab room. It's where you have all your files laid out in front of you. You can edit them, add new ones, and delete old ones freely. This is your live, hands-on workspace.
Let's create a file:
echo "Hello, World!" > hello.txtStep 3: Check Your Progress (hug s) β
How do you know what you've changed? Ask your lab assistant for a status report.
hug slhug sl (Status + List changes) gives you a quick, colorful summary of what's going on in your lab. It will tell you about any new or modified files on your lab table.
Step 4: Prepare Your Snapshot (hug aa) β
Before creating a permanent save point, you need to tell your lab assistant what to include. This is called "staging".
The staging area is your lab's preparation counter. You move the finished parts of your experiment from the main lab table to this counter, getting them ready to be officially recorded.
The easiest way to do this is with hug aa:
hug aahug aa (Add All) moves all the changes from your lab table to the preparation counter.
Now's a good time to check status with hug sl:
Step 5: Create a Save Point (hug c) β
Once your changes are on the "preparation counter," you can create a permanent snapshot, called a commit.
Lab Analogy
A commit is like a labeled moment in your lab's security camera recording. It's a snapshot of your project, frozen in time, with a descriptive message.
hug c -m "Created my first file"hug c (Commit) takes everything on the preparation counter and saves it to your project's history. The message is crucial - it's the note you're leaving for your future self!
The Loop β
That's it! Your daily workflow is a simple loop:
Pattern 1: Change β Add to Staging β Commit β
- Make changes to your code
- Check your work with
hug sl(optional) - Stage everything with
hug aa - Save your progress with
hug c -m "Describe what you did"
Pattern 2: Change Existing File β Commit β
- Make changes to an existing file
- Check your work with
hug sl(optional) - Stage & Save your progress with
hug ca -m "Describe what you did"cais for Commit All tracked files
Pattern 3: Create New File β Commit β
- Create new file and make changes
- Check your work with
hug sla(optional)slais for Status + List All
- Stage & Save your progress with
hug caa -m "Describe what you did"caais for Commit All tracked And untracked files
TIP
To learn other possible ways to add files to the staging area and to commit your changes, see:
Experimenting Safely with Separate Lab Rooms (Branches) β
What if you want to try a new, risky idea without messing up your main project? You can create a new branch.
Lab Analogy
A branch is like a separate lab room. You can make a huge mess in there, and it won't affect the clean, stable work in your main room.
1. Create and Enter a New Room (hug bc) β
Let's create a branch to test a new feature.
hug bc new-ideahug bc (Branch: Create) does two things: it creates a new lab room called new-idea and immediately moves you inside it.
2. Work in Your New Room β
Now you're in the new-idea room. You can make changes, stage them, and commit them, just like before. This history is completely separate from your main work.
echo "A brilliant new idea!" > idea.txt
hug a idea.txt
hug c -m "Add my new idea"3. Return to the Main Room (hug b) β
To go back to your main, stable project, just switch back to the main branch.
hug b mainhug b (Branch) switches you between lab rooms. Notice that idea.txt has vanished from your lab table! It's safely stored in the new-idea room, waiting for you.
TIP
Execute hug b without passing a branch name to get an interactive menu showing you all available branches.
4. Merge Your Discovery (hug m) β
If your experiment was a success, you can bring the changes from your experimental room into your main room. This is called a merge.
# Make sure you are in the main room first
hug b main
# Now, merge the work from the other room
hug m new-idea # This brings in the changes from that branch
hug c -m "Incorporate the new idea"TIP
Learn more about m* commands and the WIP workflow
Your Ultimate Safety Net: Handling Interruptions & Mistakes β
Hug makes it safe to fix common mistakes and handle interruptions without losing your progress.
Interruption: "I need to switch tasks, but my work isn't ready to commit!" β
Solution: Use Hug's WIP (Work-In-Progress) workflow. This is a safer, more robust alternative to the confusing "stash" feature found in other tools.
hug wip (Work In Progress) parks all your changes on a temporary, real branch, keeping your working directory clean (free from uncommitted changes).
hug wip "Pausing work on the login form"When you're ready to return, hug w unwip (Unpark WIP) will bring your changes right back.
Mistake #1: "I made a typo in my file, but I haven't committed yet." β
Solution: Just discard the changes from your lab table.
hug w discard hello.txt # **W**orking directory **Discard**Mistake #2: "I just made a commit, but it was wrong!" β
Solution: Tell your lab assistant to roll back the timeline by one step, but leave all your files on the lab table so you can fix them.
hug h back # **H**EAD **Back**This moves HEAD back one commit but keeps your changes staged. You can edit them and re-commit correctly.
Safety Features Built Into Hug β
Auto-Backups β
All destructive HEAD operations create automatic backup branches:
# These commands auto-create hug-backup-* branches
hug h back
hug h rollback
hug h rewind
hug h squash
# List backup branches
hug bl | grep backup
# Restore from backup if needed
hug b <backup-branch-name>Dry-Run Everything β
Always preview destructive operations first:
# Preview before executing
hug w zap-all --dry-run
hug h rollback --dry-run
hug w purge --dry-run
# Then execute with -f to skip confirmation
hug w zap-all -f # after reviewing dry-run outputInteractive Selection β
Most commands support interactive file/branch/commit selection:
# Use -- for interactive selection with Gum
hug lc "import" -- # select file to search in
hug w discard -- # select files to discard
hug bdel -- # select branch to delete
# --browse-root for full repo scope (default: current dir)
hug lc "import" --browse-rootNext Steps β
You now know the essential commands to safely manage your code with Hug. You can build entire projects with just this workflow!
When you feel more confident, explore:
- Workflows Guide - Advanced patterns and real-world scenarios
- Command Map - Complete command organization
- Cheat Sheet - Quick syntax reference
Ready to dive deeper? The Workflows Guide shows you how to combine these basics into powerful development patterns.