DEV Community

Cover image for Introducing ggc: A Git Helper Tool Written in Go
Kenta Takeuchi
Kenta Takeuchi

Posted on • Originally published at bmf-tech.com

Introducing ggc: A Git Helper Tool Written in Go

This article is a translation of Go製Git操作ツール「ggc」の紹介.

Sure! Here’s the English translation suitable for a dev.to article:


Introducing ggc: A Git Helper Tool Written in Go

What is ggc?

ggc is a Git operation helper tool implemented in Go. Its main goal is to be easy to remember, easy to use, and improve daily workflow efficiency by making everyday Git operations more comfortable.

While existing Git clients are either too feature-rich and complex or too minimal to be practical, ggc fills the gap by providing a simple and memorable command structure focused on the most commonly used Git tasks.

Features

  1. Dual interfaces: Fast CLI commands and intuitive interactive mode
  2. Composite commands: Execute multiple Git operations with a single command
  3. Incremental search: Easily select commands without memorizing them

Usage Comparison

Normal Git Workflow Using ggc
git add .git commit -m "..."git push ggc add-commit-push
git branchgit checkout <branch> ggc branch checkout (interactive)
git stashgit pullgit stash pop ggc stash-pull-pop

As shown, common workflows can be executed with a single concise command.

Main Features

  • Dual interfaces: Run commands directly with arguments or start an interactive mode without arguments
  • Interactive operations: Support for branch/file selection and commit message input
  • Comprehensive commands: Covers basic Git operations
  • Composite commands: Includes add-commit-push, stash-pull-pop, etc.
  • Lightweight design: Built only with Go standard library and golang.org/x/term
  • Supported environments: Confirmed working on macOS (Apple Silicon/Intel)

Examples

# Update to the latest state
ggc pull current

# Start working on a new branch (interactive selection)
ggc branch checkout
Enter fullscreen mode Exit fullscreen mode
# Push all changes at once
ggc add-commit-push
Enter fullscreen mode Exit fullscreen mode
# Safe merge
ggc stash-pull-pop
Enter fullscreen mode Exit fullscreen mode

Installation

Using go install

The easiest way to install is:

go install github.com/bmf-san/ggc@latest
Enter fullscreen mode Exit fullscreen mode

Set your PATH if necessary:

export PATH=$PATH:$(go env GOBIN)
Enter fullscreen mode Exit fullscreen mode

Building from source

git clone https://github.com/bmf-san/ggc
cd ggc
make build
Enter fullscreen mode Exit fullscreen mode

Place the built binary in a directory included in your PATH.

Usage

Switching Between CLI and Interactive Mode

ggc automatically switches between traditional CLI mode or interactive mode based on the presence of arguments:

# CLI mode (direct command)
ggc branch current

# Interactive mode
ggc
Enter fullscreen mode Exit fullscreen mode

Both modes are supported in a single binary, enabling flexible usage.

Selecting Commands in Interactive Mode

Running ggc without arguments opens an incremental search UI to select commands:

ggc
Enter fullscreen mode Exit fullscreen mode

Example UI:

Select a command (incremental search: type to filter, ctrl+n: down, ctrl+p: up, enter: execute, ctrl+c: exit)
Search: branch

> branch current
  branch checkout
  branch checkout-remote
  branch delete
  branch delete-merged
Enter fullscreen mode Exit fullscreen mode

How to use:

  • Type to narrow down command list
  • Use Ctrl+n / Ctrl+p to move selection
  • Press Enter to execute
  • Prompted for arguments if needed
  • Returns to selection screen after execution result

You don’t need to memorize commands—just type to filter and select intuitively.

Common Commands

ggc Command Corresponding git Command Description
ggc add <file> git add <file> Stage files
ggc add . git add . Stage all files
ggc add -p git add -p Interactive staging
ggc branch current git rev-parse --abbrev-ref HEAD Get current branch name
ggc branch checkout git branch ... → git checkout <selection> Interactive branch checkout
ggc branch checkout-remote git branch -r ... → git checkout -b <n> --track <remote>/<branch> Create and checkout remote branch
ggc branch delete git branch ... → git branch -d <selection> Interactive branch delete
ggc push current git push origin <branch> Push current branch
ggc pull current git pull origin <branch> Pull current branch
ggc log simple git log --oneline Simple log display
ggc commit <message> git commit -m <message> Create commit
ggc fetch --prune git fetch --prune Fetch and prune remote refs
ggc clean files git clean -f Clean untracked files
ggc remote add <n> <url> git remote add <n> <url> Add remote
ggc stash git stash Stash current work
ggc rebase interactive git rebase -i Interactive rebase

Composite Commands

ggc Command Git operations executed Description
ggc add-commit-push git add . → git commit → git push Stage, commit, and push in one step
ggc commit-push-interactive Interactive staging → commit → push
ggc pull-rebase-push git pull → git rebase → git push Pull, rebase, and push in one step
ggc stash-pull-pop git stash → git pull → git stash pop Stash, pull, and restore in one step

Completion Scripts

Bash and Zsh completion scripts are included.

Setup

# For bash
source /path/to/ggc/tools/completions/ggc.bash

# For zsh (same script can be used)
source /path/to/ggc/tools/completions/ggc.bash
Enter fullscreen mode Exit fullscreen mode

Add these to your .bashrc or .zshrc to enable completions automatically.

Summary

  • Intuitive usage without memorizing commands
  • Execute routine tasks with a single command
  • Interactive branch and file selection
  • Composite commands to boost workflow efficiency

Links

Top comments (0)