Git is a pretty great tool on it's own. After some time common patterns emerge. lk is here to make those patterns fast.
-
First, install
cargoby visiting https://rustup.rs. -
Install with
cargo(π¦ loki-cli ):cargo install loki-cli
lk -h
Loki: π A Git productivity tool
Usage: lk <COMMAND>
Commands:
new Create a new branch from HEAD and push it to origin. Set a prefix with --prefix or the LOKI_NEW_PREFIX env var [aliases: n]
push Push the current branch to origin with --set-upstream [aliases: p]
pull Pull with --prune deleting local branches pruned from the remote
fetch Fetch with --prune deleting local branches pruned from the remote
save Add, commit, and push using a timestamp based commit message [aliases: s]
commit Commit local changes [aliases: c]
rebase Rebase the current branch onto the target branch after fetching
worktree Manage git worktrees [aliases: w]
no-hooks Run any command without triggering any hooks [aliases: x]
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Alias: n
- Make creating a new branch easier to type by joining all given args with a dash (
-). - Automatically push and setup tracking to
origin. - Set a prefix to always prepend with the
--prefixflag or theLOKI_NEW_PREFIXenvironment variable.
β― lk new readme updates
Creates and pushes readme-updates to origin with --set-upstream. (The command git will tell you to run if you simply run git push after creating a new local branch.)
Alias: s
This is a wrapper around lk commit + lk push
- Commits current changes in tracked files (optionally all files with
--all) - Pushes via
lk push
Alias: c
- Commits current changes in tracked files (optionally all files with
--all)
Alias: p
- Pushes the current branch to origin with
--set-upstream. -f|--forceflag uses--force-with-leaseunder the hood for better force push safety.- Only works if
HEADis on a branch (not in a dettached state).
Alias: none (the alias p is for push)
- Run
git pull --pruneand remove any local branches that have also been pruned on the remote.
Alias: none
- Run
git fetch --pruneand remove any local branches that have also been pruned on the remote.
Fetch and rebase the current branch onto the target branch, or main by default.
Alias: x
Execute a git commit without running any hooks
lk x -- commit -m "Update Readme without running hooks"Alias: w
Manage git worktrees for parallel development workflows. Subcommands:
Create a new worktree as a sibling directory and set up a branch with upstream tracking.
# Creates worktree at ../my-project_fix-auth, creates and pushes branch
β― lk w a fix-auth
# With a custom base ref
β― lk w a fix-auth --base origin/develop
# With a branch prefix (via flag or LOKI_NEW_PREFIX env var)
β― lk w a fix-auth --prefix users/danigon/
# Check out an existing remote branch into a worktree
β― lk w a review-feature -b users/teammate/cool-featureIf -b points to an existing remote branch, the branch is checked out directly
instead of creating a new one.
Flags:
--base/-bβ Base ref (default:origin/main, env:LOKI_WORKTREE_BASE)--prefixβ Branch name prefix (env:LOKI_NEW_PREFIX)
Remove a worktree and delete its local branch.
# From inside the worktree β name is inferred from the directory
~/repos/my-project_fix-auth β― lk w r
# Explicit name from anywhere
~/repos/my-project β― lk w r fix-auth
# Force remove a dirty worktree
β― lk w r fix-auth --forceFlags:
--force/-fβ Force removal of dirty worktrees--prefixβ Branch name prefix used during creation (env:LOKI_NEW_PREFIX)
List all worktrees. The current worktree is highlighted in green, and other worktrees show a copy-paste command to switch to them:
β― lk w l
* my-project [main]
fix-auth [users/dan/fix-auth] lk w s fix-auth | iex
Print a cd command for switching to a worktree. Designed for use with eval:
# bash/zsh β switch to a named worktree
eval "$(lk w s fix-auth)"
# PowerShell
lk w s fix-auth | iex
# Switch to the main worktree (no name)
eval "$(lk w s)"All worktree commands output cd <path> to stdout (info goes to stderr), so you can
pipe to your shell for automatic directory switching:
# PowerShell
lk w a fix-auth | iex# bash/zsh
eval "$(lk w a fix-auth)"Analyze commits reachable from HEAD to see who has been landing work in a repository. All of the filtering flags operate on commit dates.
--namefilters by author display name (repeatable, case-insensitive).--emailfilters by author email (repeatable, case-insensitive).--first-parentrestricts the walk to the first-parent chain of HEAD (one tally per merge commit). Default walks all commits reachable from HEAD, relying on patch-id dedup to handle rebased / cherry-picked / migrated history.--no-dedupdisables patch-id deduplication (see below).
By default repo stats collapses commits that share the same git patch-id so that logically-identical changes are only counted once. This keeps contributor counts accurate when repository history contains rebased, cherry-picked, or migrated commits β for example when one repository's history was merged into another and the same patch now exists under two different SHAs.
For each patch-id group, the commit with the earliest author date is attributed to the original author. Commits with no patch (empty diffs, merge commits) are always counted individually.
When duplicates are collapsed, the summary line notes how many were removed:
Total commits: 4471 (838 duplicate patches collapsed; --no-dedup to disable)
Pass --no-dedup to count every SHA individually (the pre-2.5.0 behavior).
β― lk repo stats --weeks 4 --top 5