展示 HN:ggc – 用 Go 编写的基于终端的 Git 命令行工具
Show HN: ggc – A terminal-based Git CLI written in Go

原始链接: https://github.com/bmf-san/ggc

## ggc:一款快速且用户友好的 Git 命令行工具 ggc 是一款用 Go 编写的 Git 命令行界面 (CLI) 工具,旨在实现速度、易用性和可扩展性。它既提供传统的 CLI 命令(如 `ggc add`),也提供通过简单输入 `ggc` 即可访问的交互模式。 交互模式具有命令的增量搜索功能,简化了常见的 Git 操作,例如添加、推送、拉取、分支和查看日志。它还支持复合命令以及对分支、文件和提交消息的交互式选择。 **主要特性:** * **两种界面:** 传统 CLI 和交互式搜索。 * **全面的命令:** 涵盖了基本的 Git 功能。 * **平台支持:** macOS (Intel & Apple Silicon)、Linux 和 Windows。 * **安装:** 预编译二进制文件、安装脚本或 `go install`。 * **依赖项:** 需要 Git 和 Go 1.24+。 ggc 旨在通过现代、高效的界面简化您的 Git 工作流程。安装说明和更多详细信息请参见 [GitHub 仓库](https://github.com/bmf-san/ggc)。

## ggc:一个用Go编写的新型Git命令行工具 bmf-san推出了**ggc**,一个基于终端、用Go语言编写的新型Git命令行工具,旨在提高开发人员的生产力。它将快速、交互式的用户界面(类似于`fzf`)用于常见的Git操作,与传统的子命令和Git兼容的配置相结合。该工具具有内置别名,用于工作流程自动化,例如`ggc addcommitpush`。 该项目仍在开发中,作者正在寻求社区反馈。 Hacker News评论区的讨论迅速转移到关于Git替代方案的争论。用户们强调了**jujutsu (jj)**,这是一种具有改进基础功能的、与Git兼容的版本控制系统,以及由于Git的广泛使用和与GitHub等平台的集成,替换Git所面临的挑战。一些人还讨论了使用Git命令行包装器、纯Go Git实现(如`go-git`)以及绑定到像`libgit2`这样的库之间的性能权衡。 最终,这场对话展现了对更好Git体验的渴望,但也承认了替代方案广泛采用所面临的重大障碍。
相关文章

原文

GitHub release Go Report Card codecov GitHub license Go Reference Sourcegraph CI CodeQL Dependabot Updates

A Go Git CLI.

ggc

This logo was created by gopherize.me.

Demo

ggc is a Git tool written in Go, offering both traditional CLI commands and an interactive interface with incremental search. You can either run subcommands like ggc add directly, or launch the interactive mode by simply typing ggc. Designed to be fast, user-friendly, and extensible.

  • Traditional command-line interface (CLI): Run ggc [args] to execute specific operations directly.
  • Interactive interface: Run ggc with no arguments to launch an incremental search UI for command selection.
  • Simple commands for common Git operations (add, push, pull, branch, log, etc.)
  • Composite commands that combine multiple Git operations
  • Interactive UI for branch/file selection and message input
  • Implemented using the Go standard library and:
  • OS: macOS (Apple Silicon/Intel) - Verified
  • Go version: 1.24 or later recommended
  • Dependencies: Go standard library, golang.org/x/term, golang.org/x/sys, gopkg.in/yaml.v3
  • Requirement: git command must be installed

Pre-compiled Binaries (Recommended)

Pre-compiled binaries are available for multiple platforms and architectures. This is the fastest way to get started with ggc.

Visit the Releases page to download the latest binary for your platform:

  • macOS: darwin_amd64 (Intel), darwin_arm64 (Apple Silicon)
  • Linux: linux_amd64, linux_arm64
  • Windows: windows_amd64

Quick Install with Script

The easiest way to install ggc is using the provided installation script:

# Download and run the installation script
curl -sSL https://raw.githubusercontent.com/bmf-san/ggc/main/install.sh | bash

Or download and run it manually:

# Download the script
curl -O https://raw.githubusercontent.com/bmf-san/ggc/main/install.sh

# Make it executable
chmod +x install.sh

# Run the script
./install.sh

The script will:

  • Detect your operating system and architecture
  • Download the appropriate binary for your system
  • Install using git, manual go install fallback
  • Verify the installation
git clone <repository URL>
make build

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

For development, you can use the Makefile to install required tools and dependencies:

# Install all dependencies and tools
make deps

# Run formatter
make fmt

# Run tests
make test

# Run linter
make lint

# Run tests with coverage
make cover

# Run tests and lint
make test-and-lint

# Build with go build
make build

# Build and run with version info
make run

The Makefile will automatically install required tools like golangci-lint using go install.

Global install with go install

go install github.com/bmf-san/ggc@latest
  • The ggc binary will be installed to $GOBIN (usually $HOME/go/bin).
  • If $GOBIN is in your PATH, you can use ggc from anywhere.
  • If not, add it to your PATH:

Note

When using go install, you may get limited version info due to ldflags not working with go install. It is recommended to build with make build or use the install script or binaries.

export PATH=$PATH:$(go env GOBIN)
# or
export PATH=$PATH:$HOME/go/bin

Interactive Command Selection (Incremental Search UI)

Just run:

  • Type to filter commands (incremental search)
  • Use ctrl+n/ctrl+p to move selection, Enter to execute
  • If a command requires arguments (e.g. <file>, <name>, <url>), you will be prompted for input (always left-aligned)
  • After command execution, results are displayed and you can press Enter to continue
  • After viewing results, you return to the command selection screen for continuous use
  • Use "quit" command or ctrl+c to exit interactive mode
  • All UI and prompts are in English
Command Description
add <file> Add specific file to the index
add . Add all changes
add -p Add changes interactively
branch current Show current branch
branch checkout Checkout existing branch
branch checkout-remote Checkout remote branch
branch create Create and checkout new branch
branch delete Delete a branch
branch delete-merged Delete merged branches
branch list-local List local branches
branch list-remote List remote branches
clean files Clean untracked files
clean dirs Clean untracked directories
commit Commit staged changes
commit amend <message> Amend previous commit
commit amend --no-edit Amend without editing message
commit allow-empty Create an empty commit
commit tmp Create temporary commit
diff staged Show staged changes
diff unstaged Show unstaged changes
fetch --prune Fetch and prune remotes
log simple Show commit logs in simple format
log graph Show commit logs with a graph
pull current Pull current branch
pull rebase Pull with rebase
push current Push current branch
push force Force push current branch
rebase Rebase current branch
remote list List remotes
remote add <name> <url> Add a new remote
remote remove <name> Remove a remote
remote set-url <name> <url> Change remote URL
config list List config variables
config get <key> Get value for config key
config set <key> <value> Set config key and value
hook list List all hooks
hook install <hook> Install a hook
hook enable <hook> Enable a hook
hook disable <hook> Disable a hook
hook uninstall <hook> Remove a hook
hook edit <hook> Edit a hook
restore <file> Restore file in working directory from index
restore . Restore all files in working directory from index
restore staged <file> Unstage file (restore from HEAD to index)
restore staged . Unstage all files
restore <commit> <file> Restore file from specific commit
tag list List all tags
tag create <v> Create a tag
tag annotated <v> <msg> Create annotated tag
tag delete <v> Delete a tag
tag push Push all tags
tag push <v> Push specific tag
tag show <v> Show tag details
stash Stash current changes
stash pop Apply and remove latest stash
stash drop Remove latest stash
status short Show concise status
version Show current ggc version
main.go                  # Entry point
router/                  # Command routing logic
cmd/                     # Command entry handlers
git/                     # Git operation wrappers

Add the following to your ~/.bash_profile or ~/.bashrc:

if [ -f "$(go env GOPATH)/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.bash" ]; then
  . "$(go env GOPATH)"/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.bash
fi

Add the following to your ~/.zshrc:

if [ -f "$(go env GOPATH)/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.zsh" ]; then
  . "$(go env GOPATH)"/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.zsh
fi

Add the following to your ~/.config/fish/config.fish:

if test -f (go env GOPATH)/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.fish
    source (go env GOPATH)/pkg/mod/github.com/bmf-san/ggc@*/tools/completions/ggc.fish
end

This setup will automatically find the completion script regardless of the installed version.

Official Git Documentation

Below are the Git commands that ggc wraps, along with links to their official documentation:

  • git add - Add file contents to the index
  • git clean - Remove untracked files from the working tree
  • git restore - Restore files in the working tree
  • git push - Update remote refs along with associated objects
  • git pull - Fetch from and integrate with another repository or a local branch
  • git fetch - Download objects and refs from another repository
  • git remote - Manage set of tracked repositories
  • git status - Show the working tree status
  • git diff - Show changes between commits, commit and working tree, etc
  • git stash - Stash the changes in a dirty working directory away

Configuration and Maintenance

  • git config - Get and set repository or global options
  • git tag - Create, list, delete or verify a tag object signed with GPG
  • git rebase - Reapply commits on top of another base tip

Related Tools and Resources

  • lazygit - Simple terminal UI for Git commands
  • tig - Text-mode interface for Git
  • gitui - Blazing fast terminal-ui for Git
  • magit - Git interface for Emacs

See CONTRIBUTING.md and CODE_OF_CONDUCT.md for details.

If you’d like to support my work, please consider sponsoring me!

GitHub Sponsors – bmf-san

Or simply giving ⭐ on GitHub is greatly appreciated—it keeps me motivated to maintain and improve the project! :D

Stargazers repo roster for @bmf-san/ggc

Forkers repo roster for @bmf-san/ggc

This project is licensed under the MIT License - see the LICENSE.md file for details.

联系我们 contact @ memedata.com