gitea-tea

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gitea CLI (tea)

Gitea CLI (tea)

Overview

概述

Official command-line interface for Gitea. Manage issues, PRs, releases, and repos from terminal.
Gitea的官方命令行界面。可从终端管理Issue、PR、版本发布和仓库。

Instructions

使用说明

  1. Verify authentication: Run
    tea whoami
    to confirm login
  2. Check context: Run in git repo for auto-detection, or use
    --repo owner/repo
  3. Use non-interactive mode: Always use
    --output
    flag and provide all arguments
  4. Choose operation: See command reference sections below
  1. 验证身份认证:运行
    tea whoami
    确认登录状态
  2. 检查上下文:在Git仓库中运行可自动检测,或使用
    --repo owner/repo
    指定仓库
  3. 使用非交互模式:始终使用
    --output
    标志并提供所有必要参数
  4. 选择操作:查看下方的命令参考章节

Installation

安装

bash
undefined
bash
undefined

macOS

macOS

brew install tea
brew install tea

Linux (binary)

Linux(二进制包)

curl -sL https://dl.gitea.io/tea/main/tea-main-linux-amd64 -o tea chmod +x tea && sudo mv tea /usr/local/bin/
curl -sL https://dl.gitea.io/tea/main/tea-main-linux-amd64 -o tea chmod +x tea && sudo mv tea /usr/local/bin/

From source

从源码安装

go install code.gitea.io/tea@latest
undefined
go install code.gitea.io/tea@latest
undefined

Authentication

身份认证

bash
undefined
bash
undefined

Interactive login (recommended)

交互式登录(推荐)

tea login add
tea login add

Select: Application Token

选择:Application Token

Enter Gitea URL and token from User Settings → Applications

输入Gitea地址和从用户设置→应用中获取的token

List logins

列出登录信息

tea login list
tea login list

Set default

设置默认登录

tea login default gitea.example.com
tea login default gitea.example.com

Delete login

删除登录信息

tea login delete gitea.example.com
tea login delete gitea.example.com

Verify

验证

tea whoami
undefined
tea whoami
undefined

Issues

Issue管理

List Issues

列出Issue

bash
undefined
bash
undefined

Open issues in current repo

当前仓库中的未关闭Issue

tea issues list
tea issues list

All issues (including closed)

所有Issue(包括已关闭)

tea issues list --state all
tea issues list --state all

Filter by milestone

按里程碑筛选

tea issues list --milestone "v1.0.0"
tea issues list --milestone "v1.0.0"

Filter by assignee and labels

按指派人及标签筛选

tea issues list --assignee username --label bug,critical
tea issues list --assignee username --label bug,critical

From specific repo

指定仓库的Issue

tea issues list --repo owner/repo --login gitea.com
undefined
tea issues list --repo owner/repo --login gitea.com
undefined

View Issue

查看Issue详情

bash
undefined
bash
undefined

View issue with comments

查看Issue及评论

tea issue 42
tea issue 42

Without comments

仅查看Issue内容(不含评论)

tea issue 42 --comments=false
tea issue 42 --comments=false

Open in browser

在浏览器中打开

tea open 42
undefined
tea open 42
undefined

Create Issue

创建Issue

bash
undefined
bash
undefined

Interactive

交互式创建

tea issues create
tea issues create

With arguments

通过参数创建

tea issues create
--title "Fix authentication bug"
--body "Users cannot login with special characters"
--label bug,security
--assignee developer1
--milestone "v1.2.0"
tea issues create
--title "修复身份认证bug"
--body "用户无法使用特殊字符登录"
--label bug,security
--assignee developer1
--milestone "v1.2.0"

From file

从文件读取内容创建

tea issues create
--title "Feature request"
--body "$(cat feature-request.md)"
undefined
tea issues create
--title "功能需求"
--body "$(cat feature-request.md)"
undefined

Modify Issues

修改Issue

bash
undefined
bash
undefined

Close issue

关闭Issue

tea issues close 42
tea issues close 42

Reopen issue

重新打开Issue

tea issues reopen 42
tea issues reopen 42

Edit issue

编辑Issue

tea issues edit 42
--title "Updated title"
--assignee newdev
--add-labels "enhancement"
undefined
tea issues edit 42
--title "更新后的标题"
--assignee newdev
--add-labels "enhancement"
undefined

Pull Requests

拉取请求(PR)管理

List PRs

列出PR

bash
undefined
bash
undefined

Open PRs

未合并的PR

tea pulls
tea pulls

Closed PRs

已关闭的PR

tea pulls --state closed
tea pulls --state closed

Filter by reviewer and labels

按审核人及标签筛选

tea pulls --reviewer username --label "needs-review"
undefined
tea pulls --reviewer username --label "needs-review"
undefined

View PR

查看PR详情

bash
undefined
bash
undefined

View PR details

查看PR详细信息

tea pr 15
tea pr 15

Without comments

仅查看PR内容(不含评论)

tea pr 15 --comments=false
tea pr 15 --comments=false

Open in browser

在浏览器中打开

tea open 15
undefined
tea open 15
undefined

Create PR

创建PR

bash
undefined
bash
undefined

Interactive

交互式创建

tea pulls create
tea pulls create

With arguments

通过参数创建

tea pulls create
--title "Implement user authentication"
--description "Adds OAuth and JWT support"
--base main
--head feature/auth
--assignee reviewer1,reviewer2
--label "enhancement"
tea pulls create
--title "实现用户身份认证"
--description "添加OAuth和JWT支持"
--base main
--head feature/auth
--assignee reviewer1,reviewer2
--label "enhancement"

Description from file

从文件读取描述创建

tea pulls create
--title "Major refactor"
--description "$(cat pr-description.md)"
undefined
tea pulls create
--title "重大重构"
--description "$(cat pr-description.md)"
undefined

Checkout PR

拉取PR到本地

bash
undefined
bash
undefined

Checkout PR locally

将PR拉取到本地

tea pulls checkout 20
tea pulls checkout 20

Custom branch name

指定自定义分支名

tea pulls checkout 20 pr-20-custom-name
tea pulls checkout 20 pr-20-custom-name

Clean up checked out PRs

清理已拉取的PR分支

tea pulls clean
undefined
tea pulls clean
undefined

Review & Merge

审核与合并PR

bash
undefined
bash
undefined

Approve PR

批准PR

tea pulls approve 20 --comment "LGTM!"
tea pulls approve 20 --comment "LGTM!"

Request changes

请求修改

tea pulls reject 20 --comment "Please add tests"
tea pulls reject 20 --comment "请添加测试用例"

Leave comment

添加评论

tea pulls review 20
--state comment
--comment "Consider refactoring this section"
tea pulls review 20
--state comment
--comment "考虑重构此部分"

Merge PR (squash)

合并PR(压缩提交)

tea pulls merge 20 --style squash --message "feat: implement auth"
tea pulls merge 20 --style squash --message "feat: implement auth"

Merge PR (rebase)

合并PR(变基)

tea pulls merge 20 --style rebase
tea pulls merge 20 --style rebase

Close PR

关闭PR

tea pulls close 20
tea pulls close 20

Reopen PR

重新打开PR

tea pulls reopen 20
undefined
tea pulls reopen 20
undefined

Releases

版本发布管理

List Releases

列出版本发布

bash
tea releases list
tea releases list --limit 10
tea releases list --repo owner/project
bash
tea releases list
tea releases list --limit 10
tea releases list --repo owner/project

Create Release

创建版本发布

bash
undefined
bash
undefined

Basic release

基础版本发布

tea releases create v1.0.0
--title "Version 1.0.0"
--note "First stable release"
tea releases create v1.0.0
--title "Version 1.0.0"
--note "首个稳定版本"

From changelog file

从变更日志文件读取说明

tea releases create v1.2.0
--title "Version 1.2.0"
--note-file CHANGELOG.md
tea releases create v1.2.0
--title "Version 1.2.0"
--note-file CHANGELOG.md

Draft release

创建草稿版本

tea releases create v2.0.0-beta
--title "Beta Release"
--draft
--note "Beta for testing"
tea releases create v2.0.0-beta
--title "Beta版本"
--draft
--note "供测试用的Beta版本"

With assets

附带资产文件的版本发布

tea releases create v1.1.0-rc1
--title "Release Candidate 1"
--prerelease
--asset dist/binary-linux-amd64
--asset dist/binary-darwin-amd64
tea releases create v1.1.0-rc1
--title "Release Candidate 1"
--prerelease
--asset dist/binary-linux-amd64
--asset dist/binary-darwin-amd64

Create tag + release

创建标签并发布版本

tea releases create v1.3.0
--target main
--title "Version 1.3.0"
--note "New features"
undefined
tea releases create v1.3.0
--target main
--title "Version 1.3.0"
--note "新增功能"
undefined

Edit/Delete Release

编辑/删除版本发布

bash
undefined
bash
undefined

Update release

更新版本发布信息

tea releases edit v1.0.0
--title "Version 1.0.0 - Updated"
--note-file NEW-NOTES.md
tea releases edit v1.0.0
--title "Version 1.0.0 - 更新版"
--note-file NEW-NOTES.md

Publish draft

发布草稿版本

tea releases edit v2.0.0 --draft=false
tea releases edit v2.0.0 --draft=false

Delete release

删除版本发布

tea releases delete v0.9.0 tea releases delete v1.0.0-beta --confirm
undefined
tea releases delete v0.9.0 tea releases delete v1.0.0-beta --confirm
undefined

Labels

标签管理

bash
undefined
bash
undefined

List labels

列出标签

tea labels list tea labels list --repo owner/project tea labels list --save # Save labels to file
tea labels list tea labels list --repo owner/project tea labels list --save # 将标签保存到文件

Create label

创建标签

tea labels create bug
--color "#ff0000"
--description "Something isn't working"
tea labels create enhancement
--color "0,255,0"
--description "New feature"
tea labels create bug
--color "#ff0000"
--description "功能异常"
tea labels create enhancement
--color "0,255,0"
--description "新增功能"

Update label

更新标签

tea labels update bug --color "#cc0000" tea labels update old-name --name new-name
tea labels update bug --color "#cc0000" tea labels update old-name --name new-name

Delete label

删除标签

tea labels delete bug
undefined
tea labels delete bug
undefined

Milestones

里程碑管理

bash
undefined
bash
undefined

List milestones

列出里程碑

tea milestones list tea milestones list --state open tea milestones list --state closed
tea milestones list tea milestones list --state open tea milestones list --state closed

View milestone issues

查看里程碑关联的Issue

tea milestones issues "v1.0.0" tea milestones issues "v1.0.0" --kind pull # Only PRs tea milestones issues "v1.0.0" --state all
tea milestones issues "v1.0.0" tea milestones issues "v1.0.0" --kind pull # 仅查看PR tea milestones issues "v1.0.0" --state all

Add issue/PR to milestone

为里程碑添加Issue/PR

tea milestones issues add "v1.0.0" 42
tea milestones issues add "v1.0.0" 42

Remove issue/PR from milestone

从里程碑移除Issue/PR

tea milestones issues remove "v1.0.0" 42
tea milestones issues remove "v1.0.0" 42

Create milestone

创建里程碑

tea milestones create "v2.0.0"
--description "Major version release"
--deadline "2024-12-31"
tea milestones create "v2.0.0"
--description "大版本发布"
--deadline "2024-12-31"

Close milestone

关闭里程碑

tea milestones close "v1.0.0"
tea milestones close "v1.0.0"

Reopen milestone

重新打开里程碑

tea milestones reopen "v1.0.0"
tea milestones reopen "v1.0.0"

Delete milestone

删除里程碑

tea milestones delete "v0.9.0"
undefined
tea milestones delete "v0.9.0"
undefined

Repositories

仓库管理

bash
undefined
bash
undefined

List repos

列出仓库

tea repos list tea repos list --org myorg tea repos list --watched # Watched repos tea repos list --starred # Starred repos tea repos list --type fork # Filter: fork, mirror, source tea repos list --output yaml
tea repos list tea repos list --org myorg tea repos list --watched # 已关注的仓库 tea repos list --starred # 已标星的仓库 tea repos list --type fork # 筛选:复刻、镜像、源仓库 tea repos list --output yaml

Search repos

搜索仓库

tea repos search "keyword" --login gitea.com
tea repos search "keyword" --login gitea.com

View repo details

查看仓库详情

tea repos owner/repo
tea repos owner/repo

Create repo

创建仓库

tea repos create --name myrepo --private --init tea repos create
--name myrepo
--owner myorg
--description "My project"
--private
--init
--gitignores Go
--license MIT
tea repos create --name myrepo --private --init tea repos create
--name myrepo
--owner myorg
--description "我的项目"
--private
--init
--gitignores Go
--license MIT

Create from template

从模板创建仓库

tea repos create-from-template
--template owner/template-repo
--name new-repo
tea repos create-from-template
--template owner/template-repo
--name new-repo

Fork repo

复刻仓库

tea repos fork --repo owner/repo tea repos fork --repo owner/repo --owner myorg
tea repos fork --repo owner/repo tea repos fork --repo owner/repo --owner myorg

Delete repo

删除仓库

tea repos delete owner/repo
tea repos delete owner/repo

Clone repo (without git)

克隆仓库(无需git命令)

tea clone owner/repo tea clone owner/repo ./target-dir tea clone gitea.com/owner/repo # With host
undefined
tea clone owner/repo tea clone owner/repo ./target-dir tea clone gitea.com/owner/repo # 指定主机
undefined

Time Tracking

时间追踪

bash
undefined
bash
undefined

List time entries

列出时间条目

tea times list tea times list --issue 42 tea times list --user username tea times list --from "2024-01-01" --until "2024-12-31"
tea times list tea times list --issue 42 tea times list --user username tea times list --from "2024-01-01" --until "2024-12-31"

Add time

添加时间记录

tea times add 42 --time "2h" tea times add 42 --time "1h30m" --message "Implemented auth logic"
tea times add 42 --time "2h" tea times add 42 --time "1h30m" --message "实现身份认证逻辑"

Delete entry

删除时间条目

tea times delete 42 --id 123
undefined
tea times delete 42 --id 123
undefined

Notifications

通知管理

bash
undefined
bash
undefined

List notifications (current repo)

列出通知(当前仓库)

tea notifications list
tea notifications list

List all notifications

列出所有个人通知

tea notifications list --mine
tea notifications list --mine

Filter by type

按类型筛选

tea notifications list --types issue,pull
tea notifications list --types issue,pull

Filter by state

按状态筛选

tea notifications list --states unread,pinned
tea notifications list --states unread,pinned

Mark as read

标记为已读

tea notifications read # All filtered tea notifications read 123 # Specific ID
tea notifications read # 所有筛选出的通知 tea notifications read 123 # 指定ID的通知

Mark as unread

标记为未读

tea notifications unread 123
tea notifications unread 123

Pin/unpin

固定/取消固定

tea notifications pin 123 tea notifications unpin 123
undefined
tea notifications pin 123 tea notifications unpin 123
undefined

Organizations

组织管理

bash
undefined
bash
undefined

List organizations

列出组织

tea organizations list
tea organizations list

View organization details

查看组织详情

tea organizations myorg
tea organizations myorg

Create organization

创建组织

tea organizations create myorg
tea organizations create myorg

Delete organization

删除组织

tea organizations delete myorg
undefined
tea organizations delete myorg
undefined

Branches

分支管理

bash
undefined
bash
undefined

List branches

列出分支

tea branches list tea branches list --output json
tea branches list tea branches list --output json

View branch details

查看分支详情

tea branches main
tea branches main

Protect branch

保护分支

tea branches protect main
tea branches protect main

Unprotect branch

取消分支保护

tea branches unprotect main
undefined
tea branches unprotect main
undefined

Comments

评论管理

bash
undefined
bash
undefined

Add comment to issue or PR

为Issue或PR添加评论

tea comment 42 "This is my comment"
tea comment 42 "这是我的评论"

From specific repo

指定仓库添加评论

tea comment 42 "Comment text" --repo owner/repo
undefined
tea comment 42 "评论内容" --repo owner/repo
undefined

Admin (requires admin access)

管理员操作(需要管理员权限)

bash
undefined
bash
undefined

List users

列出用户

tea admin users list tea admin users list --output json
undefined
tea admin users list tea admin users list --output json
undefined

Non-Interactive Mode (AI Agents)

非交互模式(AI Agent适用)

IMPORTANT: When using tea in AI agent environments (no TTY), avoid interactive prompts:
bash
undefined
重要提示:在AI Agent环境(无TTY)中使用tea时,需避免交互式提示:
bash
undefined

Use --output to disable interactive mode

使用--output禁用交互模式

tea issues --output simple tea pulls --output json
tea issues --output simple tea pulls --output json

Provide ALL required arguments upfront

提前提供所有必要参数

tea issue create --title "Bug title" --body "Description here" tea pr create --title "PR title" --head feature-branch --base main
tea issue create --title "Bug标题" --body "问题描述" tea pr create --title "PR标题" --head feature-branch --base main

Use -y or --yes for confirmations

使用-y或--yes自动确认

tea pr merge 5 --yes tea releases delete v0.9.0 --yes
tea pr merge 5 --yes tea releases delete v0.9.0 --yes

Set default login to avoid prompts

设置默认登录以避免提示

tea login default <login-name>

**Always prefer explicit flags over interactive prompts.**
tea login default <login-name>

**始终优先使用显式标志而非交互式提示。**

Guidelines

操作准则

Do

建议

  • Use
    --output simple
    or
    --output json
    for non-interactive mode
  • Provide all required arguments upfront to avoid prompts
  • Run
    tea whoami
    to verify authentication before operations
  • Use
    tea open <number>
    to quickly view in browser
  • 在非交互模式下使用
    --output simple
    --output json
  • 提前提供所有必要参数以避免提示
  • 执行操作前运行
    tea whoami
    验证身份认证状态
  • 使用
    tea open <number>
    快速在浏览器中查看

Don't

不建议

  • Use interactive commands in AI agent context (no TTY)
  • Forget
    --repo owner/repo
    when outside git repository
  • Skip
    --yes
    flag for destructive operations in scripts
  • Use
    tea login add
    interactively (configure beforehand)
  • 在AI Agent环境中使用交互式命令(无TTY)
  • 在Git仓库外操作时忘记指定
    --repo owner/repo
  • 在脚本中执行破坏性操作时省略
    --yes
    标志
  • 以交互方式使用
    tea login add
    (提前配置好)

Examples

示例

Example: Feature Branch → PR

示例:功能分支→PR

bash
git checkout -b feature/new-feature
bash
git checkout -b feature/new-feature

... make changes ...

... 进行代码修改 ...

git add . && git commit -m "feat: add new feature" git push -u origin feature/new-feature tea pulls create --title "Add new feature" --base main --head feature/new-feature
undefined
git add . && git commit -m "feat: add new feature" git push -u origin feature/new-feature tea pulls create --title "添加新功能" --base main --head feature/new-feature
undefined

Example: Review & Merge PR

示例:审核并合并PR

bash
tea pulls checkout 20
bash
tea pulls checkout 20

... review code ...

... 审核代码 ...

tea pulls approve 20 --comment "LGTM!" tea pulls merge 20 --style squash
undefined
tea pulls approve 20 --comment "LGTM!" tea pulls merge 20 --style squash
undefined

Example: Create Release with Assets

示例:创建附带资产的版本发布

bash
git tag v1.0.0
git push origin v1.0.0
tea releases create v1.0.0 \
  --title "v1.0.0" \
  --note-file CHANGELOG.md \
  --asset dist/app-linux \
  --asset dist/app-darwin
bash
git tag v1.0.0
git push origin v1.0.0
tea releases create v1.0.0 \
  --title "v1.0.0" \
  --note-file CHANGELOG.md \
  --asset dist/app-linux \
  --asset dist/app-darwin