Skip to main content

ght: Github CLI Tool

Project description

Github-Tool

English

A lightweight Python CLI for managing GitHub repositories via GitHub REST API: list repos, create repos, rename repos, delete repos (single or bulk by selecting indexes), set topics, manage collaborators, and set default branch.


Features

  • Account info: show current authenticated user
  • List repos: list repositories for user or organization
  • Create repo: create user/org repos (public/private), optional description, auto-init, gitignore, license
  • Rename repo
  • Delete repo
    • Single delete by owner repo
    • Bulk delete using delete --input then select numbers like 1 4 5-8
  • Topics: set repository topics
  • Collaborators: add/remove with permissions
  • Default branch: set default branch name

Vietnamese (Tiếng Việt)

Tool CLI Python quản lý GitHub repo qua GitHub REST API: liệt kê repo, tạo repo, đổi tên, xóa (1 repo hoặc xóa hàng loạt bằng chọn số), set topics, quản lý collaborator, set default branch.


1) Requirements / Yêu cầu

Token scopes (quan trọng)

  • Repo cá nhân:
    • repo (quyền thao tác repo private/public)
    • delete_repo (để xóa repo)
  • Nếu thao tác Organization:
    • Có thể cần thêm quyền liên quan admin org tùy cấu hình org
    • Token phải thuộc user có quyền trong org

2) Install / Cài đặt

Windows

Cài Python: https://www.python.org/downloads/

Cài requests:

pip install githubclitool

Linux / macOS

Ubuntu/Debian:

sudo apt install python3 python3-pip
pip3 install githubclitool

3) Setup Token / Thiết lập Token

Windows PowerShell

$env:GITHUB_TOKEN="ghp_xxxxxxxxxxxxxxxxxxxxx"

Kiểm tra:

echo $env:GITHUB_TOKEN

Windows CMD

set GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxx

Kiểm tra:

echo %GITHUB_TOKEN%

Linux / macOS (bash/zsh)

export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxx

Kiểm tra:

echo $GITHUB_TOKEN

Using --token (không set env)

Bạn có thể truyền token trực tiếp:

ght --token ghp_xxx me

4) Basic Usage / Cách chạy

Windows

ght <command> [options]

Linux / macOS

ght <command> [options]

Xem help:

ght -h
ght <command> -h

5) Commands / Lệnh

5.1) me

English: Show current authenticated GitHub user info.
VN: Hiển thị thông tin tài khoản GitHub đang đăng nhập (token).

ght me

Output (example):

{
  "login": "YourUser",
  "id": 123456,
  "html_url": "https://github.com/YourUser"
}

5.2) list

English: List repositories by scope.
VN: Liệt kê repo theo scope.

List user repos

ght list
ght list --scope user --limit 50

List org repos

ght list --scope org:MyOrg
ght list --scope org:MyOrg --limit 200

Notes:

  • --limit giới hạn số repo in ra (không ảnh hưởng server, chỉ cắt kết quả sau khi lấy).

5.3) create

English: Create a repository (user or org).
VN: Tạo repo (user hoặc org).

Create public repo

ght create myRepo --public

Create private repo

ght create mySecretRepo --private

Create with description

ght create apiServer --public --desc "Backend API service"

Create in organization

ght create webApp --org MyOrg --private --desc "Internal web app"

Disable auto init (no README/.gitignore/license)

ght create emptyRepo --public --no-init

With gitignore and license

ght create botApi --public --gitignore Python --license mit

Parameters:

  • --public / --private: chọn visibility
  • --desc: mô tả repo (GitHub Description)
  • --org: tạo repo trong org
  • --no-init: tắt auto init (mặc định auto init bật)
  • --gitignore: template name (ví dụ Python, Node, ...)
  • --license: license template (ví dụ mit, apache-2.0, ...)

5.4) rename

English: Rename a repository.
VN: Đổi tên repo.

ght rename OwnerName oldRepo newRepo

5.5) delete (single)

English: Delete a repository by owner/repo.
VN: Xóa 1 repo theo owner repo.

ght delete OwnerName repoName --yes

Nếu không dùng --yes, tool sẽ yêu cầu confirm.


5.6) delete --input (bulk select)

English: Show repo list, then delete selected indexes.
VN: Hiển thị danh sách repo, sau đó chọn số để xóa hàng loạt.

ght delete --input --yes

Scope org:

ght delete --input --yes --scope org:MyOrg

Chọn:

  • Cách 1: 1 4 5 6 8
  • Cách 2: 1,4,5,6,8
  • Cách 3: range 5-12
  • Kết hợp: 1 3-5 9

Lưu ý an toàn:

  • Xóa repo là không khôi phục dễ dàng. Token cần quyền delete_repo.
  • Nếu không dùng --yes, tool sẽ bắt gõ DELETE để tiếp tục.

5.7) topics

English: Set repository topics.
VN: Set topics cho repo.

ght topics OwnerName repoName python bot api

5.8) add-collab

English: Add collaborator with permission.
VN: Thêm collaborator và set quyền.

ght add-collab OwnerName repoName SomeUser --perm push

Permissions:

  • pull, triage, push, maintain, admin

5.9) remove-collab

English: Remove collaborator.
VN: Xóa collaborator.

ght remove-collab OwnerName repoName SomeUser

5.10) default-branch

English: Set default branch name.
VN: Set default branch.

ght default-branch OwnerName repoName main

6) Common Problems / Lỗi thường gặp

Missing token

Error:

Missing token. Use --token or set GITHUB_TOKEN/GH_TOKEN

Fix:

  • PowerShell phải dùng:
    $env:GITHUB_TOKEN="ghp_xxx"
    
  • CMD phải dùng:
    set GITHUB_TOKEN=ghp_xxx
    
  • Hoặc truyền thẳng --token ghp_xxx

401 Bad credentials

  • Token sai / hết hạn / bị revoke
  • Chưa cấp đúng scope
  • Dùng fine-grained token nhưng chưa cấp quyền repo tương ứng

403 Forbidden

  • Thiếu quyền (đặc biệt delete_repo khi xóa)
  • Repo thuộc org nhưng token không có quyền trong org

404 Not Found

  • Sai owner/repo
  • Repo private nhưng token không có quyền access

7) Security / Bảo mật

  • Không commit token vào repo
  • Không paste token lên public chat/log
  • Nếu lộ token: revoke ngay ở GitHub settings

8) Quick Cheatsheet

ght me
ght list --scope user --limit 50
ght list --scope org:MyOrg --limit 200
ght create myRepo --public --desc "demo"
ght rename Owner oldName newName
ght topics Owner repo python api bot
ght add-collab Owner repo User --perm push
ght remove-collab Owner repo User
ght default-branch Owner repo main
ght delete Owner repo --yes
ght delete --input --yes

License

Public tool by Bugdev - Not business tool..!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

githubclitool-1.0.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

githubclitool-1.0.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file githubclitool-1.0.2.tar.gz.

File metadata

  • Download URL: githubclitool-1.0.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for githubclitool-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ebb7cc2f10b2651d8473aec53f10473827b0fe21bb55c879db59da975b363cbd
MD5 a4e521ee7b843194e083d11c4587c2f1
BLAKE2b-256 334bb7feba234650249d915d47eb9764d57c1be0f6afc8dfe2f3e80a5e973059

See more details on using hashes here.

File details

Details for the file githubclitool-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: githubclitool-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for githubclitool-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b85704aa68baf760552ff4282a06be3e2632f6f263421d8d568238ee9a5443fc
MD5 4f104e722e3f7ca097b44f29b477e647
BLAKE2b-256 74f4ef040b3c48fb762dd20d04b39dc86c15bb44ac39b9697d9346e99e857295

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page