| name | gitcode-cli |
| description | Use when managing GitCode repositories from the terminal with oh-gc CLI โ auth, issues, PRs, reviewers, testers, labels, releases, and repo config. Triggers on oh-gc commands, GitCode issue/PR management, or when user wants to interact with GitCode without a browser. |
oh-gc CLI โ GitCode Command Line Tool
Version: 0.7.4 | Updated: 2026-04-10
oh-gc is a CLI for GitCode, modeled after GitHub CLI (gh). Manages authentication, issues, pull requests, releases, and repo configuration from the terminal.
Package: npm install -g @oh-gc/cli (requires Node.js 18+)
โ ๏ธ MANDATORY FIRST STEP โ DO NOT SKIP
Run oh-gc --version as the VERY FIRST command before ANY other oh-gc command.
- If not found โ
npm install -g @oh-gc/cli@{version} (use the version shown at the top of this document)
- If the version does not match {version} โ
npm install -g @oh-gc/cli@{version} to install the exact matching version
- Do NOT run
oh-gc auth, oh-gc issue, oh-gc pr, or any other command until the version is confirmed matching.
Prerequisites
After confirming the version matches, check the following:
- Token configured? Run
oh-gc auth status
- If not logged in โ
oh-gc auth login (prompts for GitCode personal access token)
- Token obtained at: GitCode โ ไธชไบบ่ฎพ็ฝฎ โ ่ฎฟ้ฎไปค็
- Repository context? Either:
- Inside a git repo with a
gitcode.com remote (remote name configurable via oh-gc repo set-remote <name>), OR
- Use
--repo owner/repo flag to specify any repository
Global Flags
All commands support:
--json โ output raw JSON instead of formatted table
--help โ show command help
Repository Flag
Most commands that operate on a repository support the --repo flag, which allows specifying a target repository without being inside a git clone:
--repo owner/repo โ target repository in OWNER/REPO format
This is useful for:
- Operating on repositories you haven't cloned locally
- Cross-repo operations (e.g., creating a PR from fork to upstream)
- CI/CD scripts that need to interact with multiple repositories
oh-gc issue list --repo openharmony/arkui_ace_engine
oh-gc issue create --repo owner/repo --title "Bug report"
oh-gc pr view 123 --repo owner/repo
oh-gc pr create --repo upstream-owner/repo --head myname:my-feature --base main
Command Reference
Authentication
oh-gc auth login
oh-gc auth logout
oh-gc auth status
Token stored at ~/.config/gitcode-cli/config.json.
Issues
oh-gc issue list
oh-gc issue list --state closed
oh-gc issue list --state all
oh-gc issue list --assignee alice
oh-gc issue list --search "login bug"
oh-gc issue list --limit 50
oh-gc issue view 12
oh-gc issue create
oh-gc issue create --title "Bug" --body "..."
oh-gc issue create --repo owner/repo --title "Bug"
oh-gc issue create --assignee alice --labels "bug,P0"
oh-gc issue comment 12
oh-gc issue comment 12 --body "Confirmed"
oh-gc issue close 12
oh-gc issue reopen 12
oh-gc issue labels 12 bug,feature
oh-gc issue labels 12 bug --remove
oh-gc issue history 12
oh-gc issue reactions 12
oh-gc issue prs 12
oh-gc issue prs 12 --mode 1
oh-gc issue branches 12
oh-gc issue branches 12 -- feature-x,fix-y
oh-gc issue comment-get <>
oh-gc issue comment-edit <> --body
oh-gc issue comment-delete <>
oh-gc issue comment-history <>
oh-gc issue comment-reactions <>
Pull Requests
oh-gc pr list
oh-gc pr list --state merged
oh-gc pr list --state all
oh-gc pr list --author alice
oh-gc pr list --reviewer bob
oh-gc pr list --assignee carol
oh-gc pr list --limit 50
oh-gc pr view 5
oh-gc pr create
oh-gc pr create --title "Fix bug" --base main
oh-gc pr create --head feature --base main --draft
oh-gc pr create --repo owner/repo --head myname:feature
oh-gc pr update 5 --title "New title"
oh-gc pr update 5 --body "New description"
oh-gc pr update 5 --state closed
oh-gc pr update 5 --state open
oh-gc pr update 5 --draft
oh-gc update 5 --labels
oh-gc close 5
oh-gc reopen 5
oh-gc diff 5
oh-gc diff 5 --name-only
oh-gc diff 5 --color never
oh-gc merge 5
oh-gc merge 5 --method squash
oh-gc merge 5 --method rebase
oh-gc comment 5 --body
oh-gc comment 5 --body --path src/main.ts --line 10
oh-gc comment 5 --repo owner/repo --body
oh-gc comments 5
oh-gc comments 5 -- 10 --latest
oh-gc comments 5 --full-body
oh-gc comments 5 --comment-type diff_comment
oh-gc comments 5 --comment-type pr_comment
oh-gc comments 5 --delete 12345
oh-gc reactions 5
oh-gc commits 5
oh-gc reviewers 5 alice,bob
oh-gc reviewers 5 alice --append
oh-gc reviewers 5 alice --remove
oh-gc testers 5 alice,bob
oh-gc testers 5 alice --append
oh-gc testers 5 alice --remove
oh-gc review 5
oh-gc review 5 --force
oh-gc 5
oh-gc 5 --force
oh-gc labels 5 bug,enhancement
oh-gc labels 5 bug --remove
oh-gc labels 5 bug,feature --replace
oh-gc 5 1,2,3
oh-gc 5 1,2 --remove
oh-gc logs 5
oh-gc files 5
oh-gc 5
oh-gc linked-issues 5
oh-gc assignees 5 --add alice,bob
oh-gc assignees 5 --reset
oh-gc assignees 5 --reset --all
oh-gc assignees 5 --remove alice
oh-gc settings
oh-gc settings-update --merge-method squash --delete-branch-on-merge
oh-gc option-reviewers 5
oh-gc comment-get <>
oh-gc comment-edit <> --body
oh-gc comment-delete <>
oh-gc comment-history <>
oh-gc comment-reactions <>
Releases
oh-gc release create
oh-gc release create v1.0.0
oh-gc release create --prerelease
oh-gc release create v1.0.0 --notes "..."
Repo Configuration
oh-gc repo list
oh-gc repo list --org myorg
oh-gc repo create myrepo
oh-gc repo create myrepo --org myorg
oh-gc repo delete --yes
oh-gc repo fork
oh-gc repo fork --org myorg
oh-gc repo forks
oh-gc repo settings
oh-gc repo settings --disable-fork
oh-gc repo languages
oh-gc repo contributors
oh-gc repo contributors --stats
oh-gc repo events
oh-gc repo events --filter push
oh-gc repo stats --branch main
oh-gc repo stats --downloads
oh-gc repo archive --password secret
oh-gc repo archive --open --password secret
oh-gc repo transition
oh-gc repo transition --mode 2
oh-gc repo module --wiki --issues
oh-gc repo module --no-fork
oh-gc repo roles
oh-gc repo list --user alice
oh-gc repo list --visibility private
oh-gc repo get-remote
oh-gc repo set-remote upstream
oh-gc repo view
oh-gc repo update --description
oh-gc repo transfer <new-owner>
Remote override stored at .gitcode/oh-gc-config.json in repo root.
Search
oh-gc search repos "keyword"
oh-gc search issues "keyword"
oh-gc search code "keyword"
User
oh-gc user view
oh-gc user view alice
oh-gc user edit --name "New Name" --bio "..."
oh-gc user edit --avatar "https://..."
oh-gc user emails
oh-gc user followers
oh-gc user following
oh-gc user events alice
oh-gc user events alice --year 2024
oh-gc user search alice
oh-gc user search bob --sort joined_at
oh-gc user namespace alice
oh-gc user namespaces
oh-gc user namespaces --mode project
oh-gc user keys
oh-gc user key-add --title "My Key" --key "ssh-rsa ..."
oh-gc user key-delete 123
oh-gc user starred
oh-gc user starred alice
oh-gc user subscriptions
oh-gc user subscriptions alice
oh-gc user issues
oh-gc user issues --state closed --filter created
oh-gc user issues --since "2024-01-01T00:00:00Z"
oh-gc user prs
oh-gc user prs --state merged --scope assigned_to_me
oh-gc user prs --source-branch feature --target-branch main
oh-gc user orgs alice
oh-gc user membership myorg
oh-gc user leave-org myorg
Branches
oh-gc branch list
oh-gc branch list --protected
oh-gc branch get <name>
oh-gc branch create <name> --ref <sha/branch>
oh-gc branch delete <name>
oh-gc branch protect <name>
oh-gc branch protect <name> --enforce-admins
oh-gc branch protect <name> --require-status-checks ci,lint
oh-gc branch protect <name> --dismiss-stale-reviews
oh-gc branch protect <name> --unprotect
oh-gc branch protect-rules
oh-gc branch protect-rule-create <pattern> --pusher <roles> --merger <roles>
oh-gc branch protect-rule-update <pattern> --pusher <roles> --merger <roles>
oh-gc branch protect-rule-delete <pattern>
Commits
oh-gc commit list
oh-gc commit list --sha main
oh-gc commit get <sha>
oh-gc commit diff <sha>
oh-gc commit compare <base> <head>
oh-gc commit comments <sha>
oh-gc commit comment <sha> --body "text"
Files
oh-gc file get <path>
oh-gc file raw <path> --ref main
oh-gc file list
oh-gc file create <path> --content "text" --message "msg"
oh-gc file update <path> --sha <sha> --content "text" --message "msg"
oh-gc file delete <path> --sha <sha> --message "msg"
Collaborators
oh-gc collaborator list
oh-gc collaborator add <username>
oh-gc collaborator remove <username>
oh-gc collaborator permission <username>
Labels
oh-gc label list
oh-gc label create
oh-gc label update <name>
oh-gc label delete <name>
Milestones
oh-gc milestone list
oh-gc milestone get <number>
oh-gc milestone create
oh-gc milestone update <number>
oh-gc milestone delete <number>
Webhooks
oh-gc hook list
oh-gc hook get <id>
oh-gc hook create
oh-gc hook delete <id>
Tags
oh-gc tag list
oh-gc tag create <name> --ref <sha/branch>
oh-gc tag delete <name>
oh-gc tag protect <name>
oh-gc tag protect-get <name>
oh-gc tag protect-create <name> --access-level 40
oh-gc tag protect-update <name> --access-level 30
oh-gc tag protect-delete <name>
Organizations
oh-gc org list
oh-gc org view <org>
oh-gc org members <org>
Workflow: Full PR Lifecycle
Complete workflow from code change to merged PR:
Step 1: Create PR
oh-gc pr create --title "Add feature X" --base main
โ outputs PR number (e.g., #42)
Step 2: Assign people
oh-gc pr reviewers 42 alice,bob
oh-gc pr testers 42 carol
Step 3: Add metadata
oh-gc pr labels 42 feature,v2.0
oh-gc pr link 42 15,16 # Link related issues
Step 4: Review cycle
oh-gc pr diff 42 # Reviewer checks diff
oh-gc pr comments 42 # Check existing feedback
oh-gc pr comment 42 --body "LGTM"
oh-gc pr review 42 # Approve review
oh-gc pr test 42 # Mark test passed
Step 5: Merge
oh-gc pr merge 42 --method squash
Workflow: Issue Triage
Step 1: Find issues
oh-gc issue list --search "crash"
oh-gc issue list --state all --assignee alice
Step 2: Inspect
oh-gc issue view 15
Step 3: Respond
oh-gc issue comment 15 --body "Investigating, likely related to #12"
Step 4: Create follow-up
oh-gc issue create --title "Fix crash on login" --labels "bug,P0" --assignee bob
Workflow: Cross-Repo PR (Fork โ Upstream)
For contributing to repositories you don't own, use --head owner:branch format to specify the fork owner and branch:
Step 1: Create PR from fork to upstream
oh-gc pr create --repo upstream-owner/repo --head myname:my-feature --base master --title "Fix bug"
Step 2: Manage on the upstream repo
oh-gc pr view 42 --json # Check status
Note: --repo targets the upstream repo. --head uses owner:branch format (colon separator) where owner is your GitCode username and branch is the branch name in your fork. Do NOT use owner/branch (slash) โ the API requires a colon.
Configuration
| Setting | Location | How to set |
|---|
| Auth token | ~/.config/gitcode-cli/config.json | oh-gc auth login |
| Remote override | .gitcode/oh-gc-config.json | oh-gc repo set-remote <name> |
| Proxy | https_proxy / HTTPS_PROXY env var | Automatic |
Decision Tree
User wants to interact with GitCode
โ
Version matches? (oh-gc --version)
โ No โ npm install -g @oh-gc/cli@{version}
โ Yes
Logged in? (oh-gc auth status)
โ No โ oh-gc auth login
โ Yes
Inside git repo with gitcode.com remote?
โ No โ Use --repo flag, or cd to repo
โ Yes
What does user want?
โโ List/view issues โ oh-gc issue list / issue view
โโ Create issue โ oh-gc issue create
โโ Update issue โ oh-gc issue update
โโ Close/reopen issue โ oh-gc issue close / issue reopen
โโ Comment on issue โ oh-gc issue comment
โโ Manage issue labels โ oh-gc issue labels
โโ View issue history โ oh-gc issue history
โโ View issue reactions โ oh-gc issue reactions
โโ List/view PRs โ oh-gc pr list / pr view
โโ Create PR โ oh-gc pr create
โโ Update PR โ oh-gc pr update
โโ Close/reopen PR โ oh-gc pr close / pr reopen
โโ View PR reactions โ oh-gc pr reactions
โโ Review PR diff โ oh-gc pr diff
โโ Comment on PR โ oh-gc pr comment (general) or --path --line (line-level)
โโ Assign reviewers โ oh-gc pr reviewers
โโ Assign testers โ oh-gc pr testers
โโ Approve review โ oh-gc pr review
โโ Mark test passed โ oh-gc pr test
โโ Manage labels โ oh-gc pr labels
โโ Link issues to PR โ oh-gc pr link
โโ Merge PR โ oh-gc pr merge
โโ View PR history โ oh-gc pr logs
โโ Create release โ oh-gc release create
โโ Search repos/issues โ oh-gc search repos / search issues / search code
โโ View user profile โ oh-gc user view
โโ Edit user profile โ oh-gc user edit
โโ List user events โ oh-gc user events
โโ Search users โ oh-gc user search
โโ Manage SSH keys โ oh-gc user keys / user key-add / user key-delete
โโ View starred repos โ oh-gc user starred
โโ View watched repos โ oh-gc user subscriptions
โโ View namespaces โ oh-gc user namespace / user namespaces
โโ Manage branches โ oh-gc branch list / branch get / branch protect
โโ View commits/files โ oh-gc commit list / file get
โโ Manage collaborators โ oh-gc collaborator list / add / remove
โโ Manage labels โ oh-gc label list / create / update / delete
โโ Manage milestones โ oh-gc milestone list / create / update
โโ Manage webhooks โ oh-gc hook list / create / delete
โโ Configure remote โ oh-gc repo set-remote / repo get-remote
Error Handling
| Error | Cause | Fix |
|---|
| "Not logged in" | No token configured | oh-gc auth login |
| "Authentication failed" | Token expired or invalid | Re-run oh-gc auth login with new token |
| "Remote not found" | Not in a git repo or remote missing | cd to repo, check git remote -v |
| "Not a GitCode repository" | Remote URL isn't gitcode.com | Add a gitcode.com remote |
| "Could not connect" | Network issue or proxy not set | Check internet; set https_proxy env var if behind proxy |
| "Rate limit exceeded" | Too many API calls | Wait and retry |
| "API error 405" | Wrong HTTP method (internal) | Update oh-gc to latest version |
| "Can not find the branch" | --head missing fork owner prefix | Use --head owner:branch (colon, not slash) for cross-repo PRs |
URL Format
When constructing GitCode URLs for issues and PRs, use the singular form for PRs:
- Issue:
https://gitcode.com/{owner}/{repo}/issues/{number} (plural: issues)
- PR:
https://gitcode.com/{owner}/{repo}/pull/{number} (singular: pull, NOT pulls)
Common mistake: Using /pulls/ (GitHub style) instead of /pull/. GitCode uses singular pull, not pulls.
Tips
- Use
--json to pipe output to jq for scripting: oh-gc pr list --json | jq '.[].title'
- Use
--repo owner/repo to operate on any repository without cloning it first
- Interactive mode (no flags) prompts for required fields โ useful for one-off operations
oh-gc pr comments --comment-type diff_comment filters to only code review comments
oh-gc pr reviewers --append adds reviewers without replacing existing ones
oh-gc pr update --state closed is the way to close a PR without merging
- When reporting PR links to the user, always use
https://gitcode.com/{owner}/{repo}/pull/{number} (singular pull)