GIT Tools (v4.0.0+)

GitLab Release Pipeline License

This is the Go rewrite of gittool, starting from v4.0.0. For the older Java-based version (v3.x and earlier), see github.com/morimekta/gittool.

gittool is a small collection of helper programs to streamline my git usage. The main utility is gt, which wraps some git commands in an interactive interface, and makes a bit more powerful diff utility using gvim.

Extra git tools by morimekta

Usage:
  gt [command]

Available Commands:
  branch      Change branch interactively
  changelog   Print markdown changelog since the last release tag
  diff        Diff changes
  help        Help about any command
  log         Log changes
  status      Review branch status

Flags:
      --git-repository string   The git repository root directory
  -h, --help                    help for gt
      --verbose                 Show verbose output
  -v, --version                 version for gt

Install

Requires Go 1.26.1+.

go install gitlab.com/morimekta/gittool/v4/gt@latest
go install gitlab.com/morimekta/gittool/v4/[email protected]

Or build from source:

make build
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/share/gittool
sudo cp gt/gt /usr/local/bin/
sudo cp share/diffall.vim /usr/local/share/gittool

Or build and install as a .deb package:

make clean deb
sudo dpkg -i build/gittool-*.deb

Or build and install as a .rpm package (requires rpm-build):

make clean rpm
sudo rpm -i build/gittool-*.rpm

The .deb/.rpm installs gt to /usr/local/bin/ and supporting files (including diffall.vim) to /usr/local/share/gittool/. Or you can see in dl.morimekta.net for instructions on setting up apt or yum repository and install directly from there.

Commands

branch (br, b)

Interactive branch management. Displays branches with commit counts relative to the diff base, remote tracking status, and uncommitted changes marker.

Example view:

Manage branches from 'develop':
 1   develop  [+3]  -> origin/develop  Add widget support
 2 * feature  [+1]  -- MOD --  WIP: refactor login
 3   hotfix   [-2]  d: main  Fix null pointer
 4   old-wip        gone: origin/old-wip  Initial draft

Branch line legend:

  2 * feature  [+1,-2]  -- MOD --  d: develop  WIP: refactor login
  │ │ │         │   │    │          │            └─ latest commit subject
  │ │ │         │   │    │          └─ diff base (if not default branch)
  │ │ │         │   │    └─ current branch has uncommitted changes
  │ │ │         │   └─ commits on diff base not on this branch
  │ │ │         └─ commits on this branch not on diff base
  │ │ └─ branch name
  │ └─ * marks the currently checked-out branch
  └─ branch index (type to jump)

Remote tracking variants:

  1   main         -> origin/main [+1]  Merged last release
  3   gone-branch  gone: origin/gone-branch  Old feature
  • -> origin/main: branch is tracking a remote; [+N,-M] shows local vs. remote commit difference
  • gone: origin/gone-branch: remote branch has been deleted but not yet pruned

Key bindings in the selection:

  • <enter>: Check out branch
  • r: Rename branch
  • B: Set diff base for the branch
  • R: Set remote diff base
  • D: Delete selected branch
  • f: Fork new branch from selected branch
  • b: Create new branch from diff base with file selection
  • q: Exit to console

status (st)

Review branch status, showing commits since the diff base and any staged or unstaged changes.

gt status [-b branch] [-d diffbase] [-R] [-H] [-r] [-t]
  • -b branch: Show status for a specific branch instead of the current one.
  • -d diffbase: Override the diffbase branch to compare against.
  • -R: Use the remote tracking branch as diffbase (mutually exclusive with -d).
  • -H: Compare with the latest commit of the diffbase instead of the last common ancestor.
  • -r: Show file paths relative to the current directory.
  • -t: Show file paths as a tree.

diff (d)

Opens a visual diff in gvim comparing the current branch against its diff base (or a specified branch), including staged and unstaged changes. Uses the diffall.vim script to open each file pair in a separate tab with a vertical diff split.

gt diff [-b branch] [-d diffbase] [-R] [-H] [-g geometry] [paths...]
  • -b branch: Show diff for a specific branch instead of the current one.
  • -d diffbase: Override the diffbase branch to compare against.
  • -R: Use the remote tracking branch as diffbase (mutually exclusive with -d).
  • -H: Compare with the latest commit of the diffbase instead of the last common ancestor.
  • -g geometry: Set gvim window geometry (default 260x50).
  • paths...: Restrict the diff to specific files or directories. When a directory is given, only files with actual diffs within it are shown. When a file is given that has no diff, it opens a static comparison of the committed version vs the working copy.

log (l)

Show commit log between the current branch and its diff base (or remote). By default shows commits unique to the current branch (left side). Both sides can be shown simultaneously. Commit output is clipped to terminal width.

gt log [-b branch] [-l] [-r] [-R] [--no-merges] [paths...]
  • -b branch: Show log for a specific branch instead of the current one.
  • -l: Show left side — commits unique to the current branch (default: on).
  • -r: Show right side — commits unique to the diff base branch. Implied by -R unless explicitly set.
  • -R: Compare against the remote tracking branch instead of the diff base. On the default branch this is the default (since the diff base is the branch itself).
  • --no-merges: Skip merge commits.
  • paths...: Restrict the log to commits that touched the given files or directories (paths are resolved relative to the current directory).

Each commit line is prefixed with + (green) for local commits or - (red) for base/remote commits, followed by the short hash, date, and subject.

changelog (cl)

Print a markdown bullet list of commits on the current branch since the most recent release tag. Intended for drafting release notes.

gt changelog [-b branch] [-t tag] [--no-merges]
  • -b branch: Build the changelog for a specific branch instead of the current one.
  • -t tag: Start from this tag instead of the most recent one reachable from the branch. Without this flag, git describe --tags --abbrev=0 is used to pick the starting point.
  • --no-merges: Skip merge commits (default: on).

Output starts with a ## Changes since <tag> header followed by one - bullet per commit subject.

Configuration

gittool stores per-branch configuration in the git config:

  • default.branch - Override default branch detection (otherwise auto-detects master/develop/main)
  • branch.<name>.diffbase - Custom diff base for a branch (defaults to the default branch)

Release

VERSION="v1.0.0"
git tag "$VERSION"
make clean deb-all rpm-all
ls build/*.rpm build/*.deb