[软件推荐]Gitlab 发起合并请求,一行命令就搞定!

背景

每天的开发中,我们都会进行不少的合并请求,通常的路径是:打开浏览器 -> 访问私有的gitlab服务器 -> 选择项目 -> 访问合并请求的页面 -> 点击创建新的合并请求 -> 选择源分支和目标分支 -> 点击提交 -> 输入标题和内容 -> 点击创建合并请求按钮。整个过程是如此的冗长,我们也可以通过创建书签,减少一些步骤,但我觉得还是太冗长了,就在想是否有这样的工具,帮我做这件事?幸运的是有且开源🆓,主角登场>>>

简介

glab 是 Gitlab 终端操作软件,支持的命令包括但不限于创建合并请求等,极大的提升了Gitlab交互效率

安装

MacOS

使用 Homebrew, 或者直接下载EXE文件

$ brew install glab

Windows

使用 WinGet, scoop, 或者直接下载EXE文件

WinGet

$ winget install glab

Scoop

$ scoop install glab

Exe

github.com/profclems/glab/releases

其他

github.com/profclems/glab#installa...

使用

$ glab <command> <subcommand> [flags]

1.登录你的gitlab站点,创建token

通常地址为: https://your_gitlab.com/-/profile/personal_access_tokens ,创建一个token,赋予 apiwrite_repository 权限

2.授权

执行 glab auth login 授权你的 GitLab 账户

1. 选择 gitlab 站点,私有还是官方网站
? What GitLab instance do you want to log into?  [Use arrows to move, type to filter]
  gitlab.com
> GitLab Self-hosted Instance # 私有部署的 gitlab 

2. 输入提供 `web` 的服务域名
? GitLab hostname: your_gitlab.com # 输入你的gitlab网站host,如: your_gitlab.com

3. 输入 `API` 域名
? API hostname: your_gitlab.com

4. 输入上面刚刚获取的 `Token`
? Paste your authentication token: lab_dajsldjlasjdl

5. 选择默认协议
? Choose default git protocol  [Use arrows to move, type to filter]
  SSH
> HTTPS
  HTTP

6. 是否授权
? Authenticate Git with your GitLab credentials? (Y/n) Y

7. 选择 `API` 协议
? Choose host API protocol  [Use arrows to move, type to filter]
> HTTPS
  HTTP

8. 输出下面内容,表示成功了
- glab config set -h your_gitlab.com git_protocol https
✓ Configured git protocol
- glab config set -h your_gitlab.com api_protocol https
✓ Configured API protocol
✓ Logged in as yourname

核心命令

  • glab mr [list, create, close, reopen, delete, ...]
  • glab issue [list, create, close, reopen, delete, ...]
  • glab pipeline [list, delete, ci status, ci view, ...]
  • glab release
  • glab repo
  • glab label
  • glab alias

使用示例

$ glab auth login --stdin < token.txt
$ glab issue list
$ glab mr for 123   # Create merge request for issue 123
$ glab mr checkout 243
$ glab pipeline ci view
$ glab mr view
$ glab mr approve
$ glab mr merge

常用命令

# 使用当前分支,创建一个合并请求
$ glab mr create -f test/release/master(默认,也可以不输入)

了解更多

glab.readthedocs.io/en/latest/inde...

本作品采用《CC 协议》,转载必须注明作者和本文链接
Challenge Limits
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!