GitBucket CLI
gb is a command-line interface for GitBucket.
It is inspired by GitHub CLI (gh) and implemented in Rust.
This is an unofficial community project and is not affiliated with the GitBucket project.
# STATE TITLE AUTHOR LABELS
#1 OPEN Fix login page bug alice bug
#3 OPEN Add dark mode support bob enhancement
Installation
Install with Cargo
To install a specific version tag:
Build from source
Prebuilt binaries
Tagged releases publish prebuilt binaries to GitHub Releases for supported platforms. See RELEASE.md for the release process.
Requirements: Rust 1.70+ and git when installing with Cargo or building from source
Quick start
1) Authenticate
# GitBucket host or URL: gitbucket.example.com
# Personal access token: ********
# ✓ Logged in to gitbucket.example.com as alice
Create a token in GitBucket → Account Settings → Personal access tokens.
For subpath deployments, pass the base URL (or host plus path):
# or
2) Repository operations
3) Label operations
4) Milestone operations
5) Issue operations
6) Pull request operations
Command reference
| Command | Description |
|---|---|
gb auth login |
Authenticate to a GitBucket instance |
gb auth logout |
Remove auth for a host |
gb auth status [--json] |
Show current auth status |
gb auth token |
Print access token |
gb config |
Manage local CLI configuration |
gb completion <SHELL> |
Generate shell completion scripts |
gb api <ENDPOINT> |
Call the GitBucket REST API directly |
gb repo list [OWNER] |
List repositories |
gb repo view [OWNER/REPO] |
Show repository details |
gb repo create [NAME] |
Create a repository |
gb repo clone <REPO> |
Clone a repository |
gb repo delete [OWNER/REPO] |
Delete a repository |
gb repo fork [OWNER/REPO] |
Fork a repository |
gb label list |
List labels |
gb label view <NAME> |
Show label details |
gb label create [NAME] |
Create a label |
gb label edit <NAME> |
Edit a label |
gb label delete <NAME> |
Delete a label |
gb milestone list |
List milestones |
gb milestone view <NUMBER> |
Show milestone details |
gb milestone create [TITLE] |
Create a milestone |
gb milestone edit <NUMBER> |
Edit a milestone |
gb milestone delete <NUMBER> |
Delete a milestone |
gb issue list |
List issues |
gb issue view <NUMBER> |
Show issue details |
gb issue create |
Create an issue |
gb issue edit <NUMBER> |
Edit an issue |
gb issue close <NUMBER> |
Close an issue |
gb issue reopen <NUMBER> |
Reopen an issue |
gb issue comment <NUMBER> |
Add or edit an issue comment |
gb pr list |
List pull requests |
gb pr view <NUMBER> |
Show PR details |
gb pr create |
Create a pull request |
gb pr edit <NUMBER> |
Edit a pull request |
gb pr close <NUMBER> |
Close a pull request |
gb pr merge <NUMBER> |
Merge a pull request |
gb pr checkout <NUMBER> |
Checkout a PR branch |
gb pr diff <NUMBER> |
Show PR diff |
gb pr comment <NUMBER> |
Add or edit a PR comment |
gb pr comment list <NUMBER> |
List PR comments |
gb browse |
Open repository in browser |
Global options
-H, --hostname <HOST> GitBucket host or base URL
-R, --repo <OWNER/REPO> Target repository
--profile <NAME> Configuration profile
--json-errors Print failures as structured JSON on stderr
-h, --help Show help
-V, --version Show version
Repository auto-resolution
If -R/--repo is omitted, gb tries to detect OWNER/REPO from git remote get-url origin. For gb repo view, gb repo delete, and gb repo fork, you can pass OWNER/REPO positionally after the subcommand or pass -R/--repo at the subcommand.
Supported remote URL formats include:
https://gitbucket.example.com/alice/my-app.githttps://gitbucket.example.com/git/alice/my-app.githttps://gitbucket.example.com/gitbucket/alice/my-app.githttps://gitbucket.example.com/gitbucket/git/alice/my-app.gitgit@gitbucket.example.com:alice/my-app.git
Output formats
Skill Sample
This repository includes a sample Skill for AI agents that need to operate GitBucket with gb:
skills/gitbucket-cli/
The skill keeps agent-facing workflow guidance separate from the full user documentation in this README and SPEC.md.
State Filters
gb issue list, gb pr list, and gb milestone list support --state open, --state closed, and --state all.
Invalid values are rejected before the API call is made.
GitBucket Web Fallbacks
Some GitBucket actions are only exposed through the web UI, not the REST API.
When gb repo delete, gb repo fork, gb issue close, gb issue reopen, or issue metadata updates hit that case, gb falls back to a short web sign-in flow and may prompt for your password.
gb pr edit is automation-safe by default: if REST PR edit is unavailable it fails non-interactively, and uses the web fallback only when --web is passed.
When a web fallback is used, gb writes a Notice: line to stderr so scripts can distinguish REST-only success from fallback success.
For gb issue edit, the web fallback currently covers title/body/assignee/milestone/state updates. Label edits still require REST issue edit support from the target GitBucket.
Use GB_USER and GB_PASSWORD to preseed those prompts when needed.
Issue label and assignee options can be repeated or comma-separated:
gb pr create --head accepts a branch name for same-repository PRs. For cross-repository PRs, pass OWNER:BRANCH or use --head-owner OWNER --head BRANCH; after creation, the CLI prints the resolved Head: and Base: repositories and refs. Use gb pr create --detect-existing to return an existing open PR for the same head/base instead of creating a duplicate, including PRs that need to be recovered from GitBucket's issue listing. gb pr create --json and gb pr view --json print the API payload for automation; gb pr view --comments --json also includes a top-level comments array. gb pr list --state open --json fetches each open PR detail before printing JSON so fork head/base repository information matches gb pr view --json more closely.
gb pr comment --json prints the created or edited comment object; normal text output includes the comment ID and URL when GitBucket returns one. Use gb pr comment list <NUMBER> --json to inspect existing PR comments before retrying a comment mutation. gb issue list, gb issue view, gb pr list, gb pr view, and gb pr comment list accept --no-pager to force direct stdout output.
Pull Request Checkout And Diff
gb pr checkout and gb pr diff work with same-repository PRs and fork-based PRs.
When a closed PR's diff cannot be reconstructed from fetched refs, gb pr diff tries the saved PR diff URL before failing. If no saved diff can be fetched, it exits non-zero and reports whether the live diff was unavailable because a ref was missing, a base/head fetch failed, or the fetched refs had no diff.
When the PR head repository is available from the API response, gb fetches from that repository's clone URL and operates on FETCH_HEAD.
For automation, pass global --json-errors or set GB_JSON_ERRORS=true to get a single JSON error object on stderr, including fields such as error.code, error.cause, error.status, and error.exit_code.
Environment variables
| Variable | Description |
|---|---|
GB_TOKEN |
Access token (takes precedence over file config for auth) |
GB_HOST |
Default GitBucket host or base URL |
GB_REPO |
Default repository (OWNER/REPO) |
GB_PROFILE |
Default configuration profile |
GB_CONFIG_DIR |
Config directory path (default: ~/.config/gb/) |
GB_PROTOCOL |
Protocol override when using GB_TOKEN with a plain host |
GB_USER |
Username for GitBucket web-session fallbacks |
GB_PASSWORD |
Password for GitBucket web-session fallbacks |
GB_JSON_ERRORS |
Print failures as structured JSON on stderr |
NO_COLOR |
Disable colored output |
Configuration file
Credentials are stored in ~/.config/gb/config.toml (or under GB_CONFIG_DIR).
On Unix-like systems, the file is written with 0600 permissions.
= "https://gitbucket.example.com/gitbucket"
[]
= "your-personal-access-token"
= "alice"
= "https"
Plain host keys also work:
[]
= "your-personal-access-token"
= "alice"
= "https"
Profiles can select host and repository defaults, and can optionally carry credentials scoped to that profile:
= "work"
[]
= "gitbucket.example.com"
= "alice/project"
[]
= "your-work-token"
= "alice"
= "https"
--hostname / GB_HOST and --repo / GB_REPO override profile defaults. Profile-scoped credentials are tried before global [hosts] credentials for the same host.
The same GitBucket host can be used with multiple accounts by storing credentials under different profiles:
gb auth status --profile <name> prints only that profile and shows its effective actor, including whether credentials came from the profile, global host entry, or environment token. gb auth status --json exposes the same information in effective_actor for scripts.
When GB_TOKEN is set, protocol selection uses this order:
- URL scheme from
--hostnameorGB_HOSTwhen present GB_PROTOCOL- Matching stored host configuration
- Default
https
Roadmap
Current priority is to harden CI and Docker-backed verification around the existing command set before adding larger new areas.
Near term:
- Keep strengthening test and Docker-backed E2E coverage
- Keep
cargo clippy --all-targets --all-features -- -D warningsgreen in CI
After that:
- Richer issue/PR metadata handling
Lower priority / re-evaluate later:
- Webhook and collaborator operations
- Admin-oriented user management flows
Configuration commands
gb config manages the local config.toml file. It currently supports:
- printing the config file path
- listing saved hosts, profiles, and stored defaults
- reading saved host
user/protocol/has-tokenvalues - updating saved host
user/protocolvalues - creating or updating profile defaults
- setting or clearing
default_hostanddefault_profile
Token creation and token printing remain under gb auth.
API command
|
gb api calls the GitBucket REST API directly using the configured host and token.
It accepts endpoint paths relative to /api/v3, full API paths such as /api/v3/user, or absolute URLs under the configured GitBucket API base.
When --input is given and -X/--method is omitted, gb api defaults to POST.
JSON responses are pretty-printed, and empty success responses print null.
Completion command
gb completion prints shell completion scripts to stdout.
It currently supports bash, zsh, fish, and powershell.
The command does not install the scripts for you; redirect the output to the appropriate location for your shell.
Label commands
gb label manages repository label definitions through the GitBucket REST API.
It currently supports listing, viewing, creating, editing, and deleting labels in the target repository.
Colors accept 6-digit hex values with or without a leading #.
Milestone commands
gb milestone manages repository milestones.
It currently supports listing, viewing, creating, editing, and deleting milestones in the target repository.
--due-on accepts YYYY-MM-DD or RFC3339. When GitBucket returns 404 for milestone create or edit over REST, gb falls back to the GitBucket web UI flow and may prompt for GB_USER / GB_PASSWORD.
Testing
For the current automated test layout, release checks, and Docker-backed E2E workflow, see TESTING.md.
Acknowledgements
This project exists thanks to GitBucket and the community around it. Thank you for building and maintaining the software that made this CLI worth creating.
License
MIT