1
0
Fork
You've already forked gitcli
0
gitcli懒人工具
  • Go 98.3%
  • PowerShell 1.7%
2026年06月30日 17:29:08 +08:00
config gitcliv0.2 2026年04月09日 12:48:27 +08:00
git v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
utils gitcliv0.2 2026年04月09日 12:48:27 +08:00
.gitignore v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
build.ps1 v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
config.yaml v0.3.0: update gitcli 2026年06月30日 16:07:08 +08:00
gitcli-darwin-amd64 v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
gitcli-darwin-arm64 v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
gitcli-linux-amd64 v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
gitcli.exe v0.4.0: update gitcli 2026年06月30日 17:29:08 +08:00
go.mod gitcliv0.1 2026年04月09日 10:05:00 +08:00
go.sum gitcliv0.1 2026年04月09日 10:05:00 +08:00
main.go gitcliv0.2 2026年04月09日 12:48:27 +08:00
README.md v0.3.0: update gitcli 2026年06月30日 16:07:08 +08:00

gitcli

gitcli 是一个面向个人日常使用的 Git 懒人工具,主要帮你快速处理三类事情:

  • 本地裸仓库
  • Forgejo 远程仓库
  • GitHub 远程仓库

支持的操作:

  • init 初始化当前目录并关联仓库
  • new 仅创建仓库
  • rm 删除仓库
  • ls 列出仓库

命令用法

本地裸仓

gitcli init -lc <name>
gitcli new -lc <name>
gitcli rm -lc <name>
gitcli ls -lc

Forgejo 远程仓

gitcli init -rt <name> <desc> [private]
gitcli new -rt <name> <desc> [private]
gitcli rm -rt <name>
gitcli ls -rt

GitHub 远程仓

GitHub 远程仓使用 -gh 标识:

gitcli init -rt -gh <name> <desc> [private]
gitcli new -rt -gh <name> <desc> [private]
gitcli rm -rt -gh <name>
gitcli ls -rt -gh

README 初始化行为

执行 init -rtinit -rt -gh 时:

  • 如果当前目录已经存在 README.md,程序会保留现有文件,不会覆盖
  • 如果当前目录不存在 README.md,程序才会自动创建一个默认 README

这次已经把原来"每次初始化都覆盖 README.md"的逻辑改掉了。

private 默认值

[private] 用来控制创建远程仓库时,仓库是公开还是私有。

这个参数只影响 Forgejo / GitHub 远程仓库,也就是:

gitcli init -rt <name> <desc> [private]
gitcli init -rt -gh <name> <desc> [private]
gitcli new -rt <name> <desc> [private]
gitcli new -rt -gh <name> <desc> [private]

本地裸仓命令 -lc 不使用这个参数。

[private] 可以不填写。

如果不填写,程序会读取 config.yaml 中的:

default_private:false

例如:

gitcli new -rt -gh myrepo "我的 GitHub 仓库"

如果 default_private: false,就创建公开仓库。
如果 default_private: true,就创建私有仓库。

也可以在命令最后显式传入 true,临时创建私有仓库:

gitcli new -rt -gh myrepo "我的 GitHub 仓库" true

配置文件

程序会从可执行文件所在目录读取 config.yaml

唯一支持的配置格式:

forgejo_url:http://192.168.2.168:3000token:your_forgejo_tokengithub_api_url:https://api.github.comgithub_token:your_github_tokendefault_private:falselocal_repo_path:D:/gitea_repos

配置项说明

  • forgejo_url: Forgejo 服务地址
  • token: Forgejo token
  • github_api_url: GitHub API 地址,通常固定为 https://api.github.com
  • github_token: GitHub token
  • default_private: 不填写 [private] 时的默认值
  • local_repo_path: 本地裸仓库存放目录

跨平台路径说明

local_repo_path 需要按系统填写。

Windows

local_repo_path:D:/gitea_repos

或:

local_repo_path:C:/Users/yourname/gitea_repos

Linux

local_repo_path:/home/yourname/gitea_repos

macOS

local_repo_path:/Users/yourname/gitea_repos

如果你不填写 local_repo_path,程序会自动给一个默认目录:

  • Windows: ~/gitea_repos
  • Linux: ~/gitea_repos
  • macOS: ~/gitea_repos

注意

  • GitHub API 地址要写 https://api.github.com,不要写 https://github.com
  • GitHub 命令要写 -gh,例如 gitcli ls -rt -gh
  • 当前程序只识别 -gh,不识别 gh
  • 不要把真实 token 提交到仓库里