[軟件推薦] Gitlab 發(fā)起合并請(qǐng)求,一行命令就搞定!

背景

每天的開(kāi)發(fā)中,我們都會(huì)進(jìn)行不少的合并請(qǐng)求,通常的路徑是:打開(kāi)瀏覽器 -> 訪問(wèn)私有的gitlab服務(wù)器 -> 選擇項(xiàng)目 -> 訪問(wèn)合并請(qǐng)求的頁(yè)面 -> 點(diǎn)擊創(chuàng)建新的合并請(qǐng)求 -> 選擇源分支和目標(biāo)分支 -> 點(diǎn)擊提交 -> 輸入標(biāo)題和內(nèi)容 -> 點(diǎn)擊創(chuàng)建合并請(qǐng)求按鈕。整個(gè)過(guò)程是如此的冗長(zhǎng),我們也可以通過(guò)創(chuàng)建書(shū)簽,減少一些步驟,但我覺(jué)得還是太冗長(zhǎng)了,就在想是否有這樣的工具,幫我做這件事?幸運(yùn)的是有且開(kāi)源??,主角登場(chǎng)>>>

簡(jiǎn)介

glab 是 Gitlab 終端操作軟件,支持的命令包括但不限于創(chuàng)建合并請(qǐng)求等,極大的提升了Gitlab交互效率

安裝

MacOS

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

$ brew install glab

Windows

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

WinGet

$ winget install glab

Scoop

$ scoop install glab

Exe

https://github.com/profclems/glab/releases

其他

https://github.com/profclems/glab#installation

使用

$ glab <command> <subcommand> [flags]

1.登錄你的gitlab站點(diǎn),創(chuàng)建token

通常地址為: https://your_gitlab.com/-/profile/personal_access_tokens ,創(chuàng)建一個(gè)token,賦予 apiwrite_repository 權(quán)限

2.授權(quán)

執(zhí)行 glab auth login 授權(quán)你的 GitLab 賬戶

1. 選擇 gitlab 站點(diǎn),私有還是官方網(wǎng)站
? 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` 的服務(wù)域名
? GitLab hostname: your_gitlab.com # 輸入你的gitlab網(wǎng)站host,如: your_gitlab.com

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

4. 輸入上面剛剛獲取的 `Token`
? Paste your authentication token: lab_dajsldjlasjdl

5. 選擇默認(rèn)協(xié)議
? Choose default git protocol  [Use arrows to move, type to filter]
  SSH
> HTTPS
  HTTP
  
6. 是否授權(quán)
? Authenticate Git with your GitLab credentials? (Y/n) Y

7. 選擇 `API` 協(xié)議
? Choose host API protocol  [Use arrows to move, type to filter]
> HTTPS
  HTTP

8. 輸出下面內(nèi)容,表示成功了
- 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

常用命令

# 使用當(dāng)前分支,創(chuàng)建一個(gè)合并請(qǐng)求
$ glab mr create -f test/release/master(默認(rèn),也可以不輸入)

了解更多

https://glab.readthedocs.io/en/latest/index.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容