# Get git branch

> Get git branch is an open-source agent skill for developer tools. Restores full remote branch fetching in a Git repo cloned with a single-branch refspec. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ruan-cat/monorepo/tree/main/ai-plugins/low-frequency-skill/skills/get-git-branch
- **Repository:** https://github.com/ruan-cat/monorepo
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** get-git-branch
- **Collection:** https://github.com/ruan-cat/monorepo
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill helps when a local Git clone only shows the default branch even though the remote has more. It explains that shallow or single-branch clones narrow the fetch refspec in .git/config, so fetch never requests other branches. The agent is guided to compare the configured refspec with the branches the remote actually advertises before changing anything.

The workflow runs a few read-only checks (listing local branches, reading the origin fetch setting, querying remote heads), then switches the refspec to a wildcard pattern and runs a full fetch to bring in every remote branch. It also covers converting a shallow clone to full history, but only when the user asks for it, and lists fallback checks such as network access, permissions, pruning stale refs and other remotes.

It expects a Git repository with an origin remote and access to run git commands in a shell. The instructions are written in Chinese and the trigger phrases are Chinese as well.

## When your agent uses it

> 诊断并修复 Git 仓库无法看到所有远程分支的问题，将受限的 fetch refspec 恢复为通配符模式， 使 git fetch 能拉取全部远程分支。当用户提及「看不到远程分支」「分支不全」 「只有 master/main」「fetch 所有分支」「shallow clone 补全分支」 「--single-branch 修复」「远程分支丢失」「获取全部分支」等关键词时使用此技能。 即使用户没有明确提到 refspec 或 shallow clone，只要意图是让仓库能看到并拉取所有远程分支， 就应触发此技能。

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ruan-cat/monorepo/tree/HEAD/ai-plugins/low-frequency-skill/skills/get-git-branch)
- [License: MIT](https://github.com/ruan-cat/monorepo/tree/HEAD/ai-plugins/low-frequency-skill/skills/get-git-branch)

## Features

- **Diagnose narrowed fetch refspec:** Checks the origin fetch setting and compares local branches with remote heads to confirm the cause.
- **Restore wildcard fetch pattern:** Changes the fetch rule so Git retrieves all remote branch references again.
- **Fetch all remote branches:** Runs a full fetch and verifies that every remote branch appears locally.
- **Convert shallow clone to full:** Optionally unshallows a depth-limited clone when full commit history is needed.
- **Fallback troubleshooting steps:** Lists further checks such as network, permissions, pruning and multiple remotes.

## Good for

- Make my cloned repo show all remote branches
- Fix a shallow clone that only has main
- Fetch every branch after a single-branch clone
- Find out why git branch -a shows so few branches

## Install

### Claude Code

This skill ships in the `low-frequency-skill` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ruan-cat/monorepo
/plugin install low-frequency-skill@ruan-cat-tools
```

Or copy only this skill to `~/.claude/skills/get-git-branch`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/get-git-branch &&
cp -R "$tmp/ai-plugins/low-frequency-skill/skills/get-git-branch" ~/.claude/skills/get-git-branch &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/get-git-branch` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/get-git-branch` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/get-git-branch &&
cp -R "$tmp/ai-plugins/low-frequency-skill/skills/get-git-branch" ~/.agents/skills/get-git-branch &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/get-git-branch` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/get-git-branch` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/get-git-branch &&
cp -R "$tmp/ai-plugins/low-frequency-skill/skills/get-git-branch" ~/.cursor/skills/get-git-branch &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/get-git-branch` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ruan-cat/monorepo.git --path ai-plugins/low-frequency-skill/skills/get-git-branch
```

Or copy the folder to `~/.gemini/skills/get-git-branch` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/get-git-branch`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ruan-cat/monorepo.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/get-git-branch &&
cp -R "$tmp/ai-plugins/low-frequency-skill/skills/get-git-branch" ~/.copilot/skills/get-git-branch &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/get-git-branch` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ruan-cat/monorepo.git
```

Then copy `monorepo/ai-plugins/low-frequency-skill/skills/get-git-branch` into your agent's skills folder as `get-git-branch`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What causes the missing branches?

A clone made with --depth=1 or --single-branch sets the origin fetch refspec to only the default branch, so other remote branches are not fetched.

### Does the skill change my local branches or working tree?

It says changing the fetch refspec is safe and that git fetch --all does not create local branches or modify the working tree.

### Will Get git branch download the full commit history?

Not by default. Unshallowing the repository only happens when the user explicitly asks for full history.

### How do I install Get git branch in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/get-git-branch to use it in all your projects, or to .claude/skills/get-git-branch in one project. Or install the low-frequency-skill plugin, which includes it: /plugin marketplace add ruan-cat/monorepo, then /plugin install low-frequency-skill@ruan-cat-tools.

### Does Get git branch run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Get git branch?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Get git branch?

The closest alternatives to Get git branch are Git branch cleanup, Rebase current branch, Branch, Clone ruancat repo and Rebase2main.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Git branch cleanup](https://ai-powered.com/skills/git-branch-cleanup): Git branch cleanup is an open-source agent skill for developer tools.
- [Rebase current branch](https://ai-powered.com/skills/rebase-current-branch): Rebase current branch is an open-source agent skill for developer tools.
- [Branch](https://ai-powered.com/skills/branch-tjmonsi): Branch is an open-source agent skill for developer tools.
- [Clone ruancat repo](https://ai-powered.com/skills/clone-ruancat-repo): Clone ruancat repo is an open-source agent skill for developer tools.
- [Rebase2main](https://ai-powered.com/skills/rebase2main): Rebase2main is an open-source agent skill for developer tools.
- [Check a stale branch is not undoing newer main work](https://ai-powered.com/skills/check-a-stale-branch-is-not-undoing-newer-main-work): Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools.
- [Gha PR merge ref shows upstream changes](https://ai-powered.com/skills/gha-pr-merge-ref-shows-upstream-changes): Gha PR merge ref shows upstream changes is an open-source agent skill for developer tools.
- [Docs branch off feature branch smuggles code](https://ai-powered.com/skills/docs-branch-off-feature-branch-smuggles-code): Docs branch off feature branch smuggles code is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/get-git-branch
