Atomic commit practices and worktree management for the MT project.
Each commit should contain a single, complete, and coherent unit of work. "Don't mix your apples with your toaster."
- Debugging:
git bisectto rapidly identify problems - Code History: Organized, understandable commit logs
- Collaboration: Focused code reviews
- Safe Operations: Revert or cherry-pick without side effects
# Interactive mode - select which files/hunks to stage
git add -i
# Patch mode - directly choose hunks to stage
git add -p <file>
# Other patch commands
git reset --patch # Unstage specific hunks
git checkout --patch # Discard specific hunks
git stash save --patch # Stash specific hunks| Key | Action |
|---|---|
s / 1 |
View status (staged vs unstaged) |
u / 2 |
Stage files |
r / 3 |
Unstage files |
a / 4 |
Add untracked files |
p / 5 |
Patch mode (select hunks) |
d / 6 |
View diff of staged files |
| Key | Action |
|---|---|
y |
Stage this hunk |
n |
Skip this hunk |
s |
Split into smaller hunks |
e |
Manually edit the hunk |
q |
Quit |
a |
Stage this + all later hunks |
d |
Skip this + all later hunks |
g |
Jump to a specific hunk |
/ |
Search hunks by regex |
git statusandgit diffto review changesgit add -ito enter interactive mode- Stage related files with
u - Use
pfor files with mixed changes - Use
sto split large hunks - Review with
d, thenqto exit git commit -m "descriptive message"- Repeat for remaining changes
- Review history:
git log --oneline - When ready, offer to squash:
git rebase -i HEAD~N
The project uses worktrunk (wt) for managing git worktrees.
wt list # List existing worktrees
wt switch feature # Switch to existing worktree
wt switch --create feature # Create new worktree from HEAD
wt switch --create feature --base=main # Create from specific branch
wt switch -c feature -x "cargo tauri dev" # Create and run command
wt switch ^ # Switch to default branch
wt switch - # Switch to previous worktreewt merge # Full: squash, rebase, merge, cleanup
wt merge develop # Merge to specific branch
wt merge --no-squash # Keep commit history
wt merge --no-remove # Keep worktree after merge
wt merge -y # Skip approval prompts
wt merge main -y --no-remove # Combined optionswt merge pipeline:
- Squash - Combine commits since target into one
- Rebase - Rebase onto target if behind
- Pre-merge hooks - Run tests/lint
- Merge - Fast-forward merge
- Cleanup - Remove worktree and branch
wt merge --stage=all # Default: untracked + unstaged
wt merge --stage=tracked # Only tracked changes
wt merge --stage=none # Only already-stagedwt step squash # Squash commits
wt step rebase # Rebase onto target
wt step push # Push to remote
wt step for-each -- git status # Run in all worktreeswt remove # Remove current worktree
wt remove feature # Remove by branch name
wt remove feature --no-delete-branch # Keep branch
wt remove feature -D # Force delete unmerged