Tyler 6dd33b5f4f docs(login): make the git credential helper discoverable (#1014)
Closes #1013.

## Background

While trying to use `tea` from a non-interactive context I hit a friction point: after `tea login add` succeeded, plain `git push` over HTTPS still prompted for credentials. I filed #1013 as a feature request to add credential helper integration — then found, on reading the source, that the integration **already exists**:

- `tea login add` accepts `--helper` (alias `-j`), which calls `task.SetupHelper` to register a credential helper in `~/.gitconfig`.
- `tea login helper get` correctly implements git's credential protocol, reading the request from stdin and returning `protocol`/`host`/`username`/`password` lines.
- `tea login helper setup` does the same for every configured login.

I verified end-to-end that this works as advertised: after `tea login helper setup`, an HTTPS `git push` against a configured Gitea host authenticates silently using the stored token, no prompts, with `GIT_TERMINAL_PROMPT=0` set as a safety check.

So the feature is fine. The problem is that nobody can find it:

| Surface | Before | Issue |
|---|---|---|
| Flag name on `tea login add` | `--helper` (alias `-j`) | Generic; nothing tying it to git or credentials |
| Flag usage text | `"Add helper"` | Says nothing |
| `tea login helper` command | `Hidden: true` | Not in `tea login --help` |
| `tea login helper` usage | `"Git helper"` | Says nothing |
| `tea login helper` description | `"Git helper"` | Same string again |
| `store/erase` subcommand description | `"Command drops"` | Sentence fragment, no meaning |
| `setup` subcommand description | `"Setup helper to tea authenticate"` | Awkward, doesn't explain what it touches |
| `get` subcommand description | `"Get token to auth"` | Doesn't mention git, stdin, or the credential protocol |
| Mention in `tea login add --help` | None | Feature is invisible |

## What this patch does

Purely cosmetic / documentation changes — **no behavior changes**:

1. Renames `--helper` to `--git-credentials`, keeping `--helper` and `-j` as aliases so existing scripts and muscle memory keep working.
2. Removes `Hidden: true` from `tea login helper` so it appears in `tea login --help`.
3. Rewrites every placeholder `Usage` and `Description` string in the helper command tree to describe what the thing actually does.
4. Expands the top-level `Description` of `tea login add` to mention the option and explain what it does.
5. Prints a one-line hint after a successful non-helper login: `Tip: pass --git-credentials (or run 'tea login helper setup') to authenticate 'git push' and 'git clone' over HTTPS with this token.`

The credential helper protocol implementation, `SetupHelper`'s gitconfig writes, and the `get`/`store`/`setup` action functions are all unchanged.

## Help output after the patch

```
$ tea login --help
COMMANDS:
   ...
   helper, git-credential  Act as a git credential helper for stored Gitea logins
   ...

$ tea login helper --help
NAME:
   tea logins helper - Act as a git credential helper for stored Gitea logins

DESCRIPTION:
   Speaks git's credential helper protocol so that HTTPS push and clone
   operations against your configured Gitea instances authenticate silently
   using the tokens tea already stores.

   Typical use is automatic: 'tea login add --git-credentials' (or 'tea login
   helper setup' for existing logins) registers '!tea login helper' as a
   credential helper in ~/.gitconfig. Git then invokes the 'get' subcommand
   when it needs credentials for a configured host.

COMMANDS:
   store, erase  No-op (git credential protocol store/erase)
   setup         Register tea as a git credential helper for every configured login
   get           Return the stored token for a URL (git credential protocol)
```

## Open questions for the reviewer

A few choices in here that are subjective — happy to change any of them:

- **Flag name**: `--git-credentials` was the first clear name I tried. `--credential-helper` and `--git-helper` are also reasonable. Or keep `--helper` as canonical and just fix its usage text.
- **Canonical subcommand name**: I kept `helper` as canonical with `git-credential` as alias, matching what was already there. Could flip this — `gh` uses `gh auth git-credential` as canonical with no `helper` form.
- **Should `--git-credentials` default to true?** Most users probably want it on; the current opt-in design surprises them. But flipping the default is a behavior change so I left it alone here.
- **Should the hint be silenced by an env var or a config flag?** I left it always-on for the people who need to see it; can gate it if it bothers automation users.
- **Teardown on `tea login delete`** would parallel the setup behavior, but is genuinely a separate change. Not in this PR.

---

This patch was authored interactively with an AI assistant, driven and reviewed by a human (Tyler / @dinsmoor) every step.

*pull request created by Tyler's lovingly wrangled demon machine <3*

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/1014
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Tyler <tyler@dinsmoor.us>
Co-committed-by: Tyler <tyler@dinsmoor.us>
2026-05-28 17:38:58 +00:00
2023-10-23 18:36:38 +00:00
2026-05-26 21:14:47 +00:00
2020-12-14 20:33:54 +08:00
2025-02-27 18:33:37 +00:00
2026-02-02 22:39:26 +00:00
2023-09-08 01:40:02 +00:00
2018-09-03 14:43:00 +08:00
2024-12-27 02:00:57 +00:00
2026-02-02 23:05:45 +00:00
2026-02-02 23:05:45 +00:00
2026-05-14 16:24:31 +00:00

tea logo T E A

License: MIT Release Join the chat at https://img.shields.io/discord/322538954119184384.svg Go Report Card GoDoc Tea Release Status

The official CLI for Gitea

demo gif

NAME:
  tea - command line tool to interact with Gitea

USAGE:
  tea [global options] [command [command options]]

VERSION:
  Version: 0.10.1+15-g8876fe3  golang: 1.25.0  go-sdk: v0.21.0

DESCRIPTION:
  tea is a productivity helper for Gitea. It can be used to manage most entities on
  one or multiple Gitea instances & provides local helpers like 'tea pr checkout'.

  tea tries to make use of context provided by the repository in $PWD if available.
  tea works best in a upstream/fork workflow, when the local main branch tracks the
  upstream repo. tea assumes that local git state is published on the remote before
  doing operations with tea.    Configuration is persisted in $XDG_CONFIG_HOME/tea.

COMMANDS:
  help, h  Shows a list of commands or help for one command

  ENTITIES:
    issues, issue, i                  List, create and update issues
    pulls, pull, pr                   Manage and checkout pull requests
    labels, label                     Manage issue labels
    milestones, milestone, ms         List and create milestones
    releases, release, r              Manage releases
    times, time, t                    Operate on tracked times of a repository's issues & pulls
    organizations, organization, org  List, create, delete organizations
    repos, repo                       Show repository details
    branches, branch, b               Consult branches
    actions                           Manage repository actions (secrets, variables)
    comment, c                        Add a comment to an issue / pr
    webhooks, webhook                 Manage repository webhooks

  HELPERS:
    open, o                         Open something of the repository in web browser
    notifications, notification, n  Show notifications
    clone, C                        Clone a repository locally

  MISCELLANEOUS:
    whoami    Show current logged in user
    admin, a  Operations requiring admin access on the Gitea instance

  SETUP:
    logins, login  Log in to a Gitea server
    logout         Log out from a Gitea server

GLOBAL OPTIONS:
  --debug, --vvv  Enable debug mode (default: false)
  --help, -h      show help
  --version, -v   print the version

EXAMPLES
  tea login add                       # add a login once to get started

  tea pulls                           # list open pulls for the repo in $PWD
  tea pulls --repo $HOME/foo          # list open pulls for the repo in $HOME/foo
  tea pulls --remote upstream         # list open pulls for the repo pointed at by
                                      # your local "upstream" git remote
  # list open pulls for any gitea repo at the given login instance
  tea pulls --repo gitea/tea --login gitea.com

  tea milestone issues 0.7.0          # view open issues for milestone '0.7.0'
  tea issue 189                       # view contents of issue 189
  tea open 189                        # open web ui for issue 189
  tea open milestones                 # open web ui for milestones

  tea actions secrets list            # list all repository action secrets
  tea actions secrets create API_KEY  # create a new secret (will prompt for value)
  tea actions variables list          # list all repository action variables
  tea actions variables set API_URL https://api.example.com

  tea webhooks list                   # list repository webhooks
  tea webhooks list --org myorg       # list organization webhooks
  tea webhooks create https://example.com/hook --events push,pull_request

  # send gitea desktop notifications every 5 minutes (bash + libnotify)
  while :; do tea notifications --mine -o simple | xargs -i notify-send {}; sleep 300; done

ABOUT
  Written & maintained by The Gitea Authors.
  If you find a bug or want to contribute, we'll welcome you at https://gitea.com/gitea/tea.
  More info about Gitea itself on https://about.gitea.com.

Installation

There are different ways to get tea:

  1. Install via your system package manager:

    • macOS via brew (official):
      brew install tea
      
    • arch linux (tea, thirdparty)
    • alpine linux (tea, thirdparty)
    • Windows via MSYS2 (tea, thirdparty)
  2. Use the prebuilt binaries from dl.gitea.com

  3. Install from source: see Compilation

  4. Docker: Tea at docker hub

Log in to Gitea from tea

Gitea can use many different authentication schemes, and not every authentication method will work with every Gitea deployment. When you are a Gitea instance administrator you can tweak your settings to fit your use case. For the method that is most likely to work with any Gitea deployment use the following steps:

  1. Open your Gitea instance in a web browser

  2. Log in to Gitea in your web browser. Any MFA, IDP, or whatever else should be available this way.

  3. In your "user settings", generate an application token with at least user read permissions. If you want to do anything useful with the token add additional permissions/scopes.

  4. Run tea login add, select application token authentication when asked for authentication type, and answer yes to the question if you have a token. Paste the generated token when asked for one.

You should now be logged in to your gitea instance from tea.

Since 0.10 Gitea supports the much simpler oauth workflow but oauth may not be available on all Gitea deployments, and gets much more complex when running tea on a remote system.

Shell completion

If you installed from source or the package does not provide the completions with it you can add them yourself with tea completion <shell> command which is not visible in help. To generate the completions run one of the following commands depending on your shell.

# .bashrc
source <(tea completion bash)

# .zshrc
source <(tea completion zsh)

# fish
tea completion fish > ~/.config/fish/completions/tea.fish

# Powershell
Output the script to path/to/autocomplete/tea.ps1 an run it.

Man Page

The hidden command tea man can be used to generate the tea man page.

# for bash or zsh
man <(tea man)

# for fish
man (tea man | psub)

# write man page to a file
tea man --out ./tea.man

Compilation

Make sure you have a current Go version installed (1.26 or newer).

  • To compile the source yourself with the recommended flags & tags:

    git clone https://gitea.com/gitea/tea.git # or: tea clone gitea.com/gitea/tea ;)
    cd tea
    make
    

    Note that GNU Make (gmake on OpenBSD) is required. If you want to install the compiled program you have to execute the following command:

    make install
    

    This installs the binary into the "bin" folder inside of your GOPATH folder (go env GOPATH). It is possible that this folder isn't in your PATH Environment Variable.

  • For a quick installation without git & make, set $version and exec:

    go install gitea.dev/tea@${version}
    

Contributing

Fork -> Patch -> Push -> Pull Request

  • make test run testsuite
  • make vet run checks (check the order of imports; preventing failure on CI pipeline beforehand)
  • ... (for other development tasks, check the Makefile)

Please read the CONTRIBUTING documentation, it will tell you about internal structures and concepts.

License

This project is under the MIT License. See the LICENSE file for the full license text.

S
Description
A command line tool to interact with Gitea servers
Readme MIT 28 MiB
Languages
Go 99.2%
Makefile 0.5%
Shell 0.1%
Nix 0.1%