Get the FREE Ultimate OpenClaw Setup Guide →

managing-branches

Scanned
npx machina-cli add skill aiskillstore/marketplace/managing-branches --openclaw
Files (1)
SKILL.md
1.2 KB

Branch Investigation

git branch --show-current
git status --short
git fetch --all
git branch -vv
git rev-list --count <main-branch>..HEAD 2>/dev/null || echo "0"  # Check CLAUDE.md for main branch name

Report: current branch, uncommitted changes, remote sync status, commits ahead of main.

Branch Creation

git fetch origin <base-branch>
git checkout -b <new-branch> origin/<base-branch>

Error Handling

ErrorAction
Branch existsReport to user, suggest alternative or confirm use existing
Uncommitted changesgit stash or commit first
Remote sync errorgit fetch --all retry
Permission errorReport to user

Conflict Resolution

  1. git status to identify conflicts
  2. Resolve each file
  3. git add <resolved-file>
  4. Continue operation

Ask for guidance if resolution is complex.

Completion Report

  • Current branch name
  • Branch creation result (if applicable)
  • Any issues encountered

Source

git clone https://github.com/aiskillstore/marketplace/blob/main/skills/1gy/managing-branches/SKILL.mdView on GitHub

Overview

The managing-branches skill inspects repository state (current branch, status, remote sync, and commits ahead of base) and can create new branches from a specified base. It triggers on branch status checks, new-branch requests, and branch-related errors, and relies on Bash Git commands to produce a precise report and actionable steps.

How This Skill Works

It executes a defined sequence of Git commands to reveal branch state: showing the current branch, short status, and remote synchronization, plus a count of commits ahead of the base. When you request a new branch, it fetches origin for the base-branch and checks out a new branch from origin/<base-branch>. If errors arise, it follows the structured error handling table to guide resolution. Note: the main/base branch name may vary; refer to your workflow (CLAUDE.md) to specify the correct base when needed.

When to Use It

  • When a branch status check indicates you should verify state before proceeding
  • When you need to start work on a new feature or bugfix by creating a branch from a stable base
  • When you encounter branch-related errors (e.g., branch exists, uncommitted changes, remote sync issues, or permission problems) and need guided actions
  • When you want to synchronize with the remote and assess how far your branch is ahead of the base
  • When you need a concise completion report summarizing current branch, creation outcome, and any issues

Quick Start

  1. 1) Run the investigation commands to report state: git branch --show-current; git status --short; git fetch --all; git branch -vv; git rev-list --count <main-branch>..HEAD 2>/dev/null || echo "0" # Check CLAUDE.md for main branch name
  2. 2) Decide on a base-branch and the new-branch name you want to create
  3. 3) Create the new branch from origin/<base-branch>: git fetch origin <base-branch>; git checkout -b <new-branch> origin/<base-branch>
  4. 4) If you hit an error, consult the Error Handling table and proceed accordingly

Best Practices

  • Keep your local worktree clean before creating a new branch (commit or stash changes)
  • Always fetch updates from origin before creating or switching branches
  • Use descriptive, machine-parseable branch names (e.g., feature/login-redesign, bugfix/auth-timeout)
  • Ensure you’re branching from the correct base (origin/<base-branch>) to minimize merge conflicts
  • After creating a branch, verify its tracking status (git branch -vv) and confirm you’re ahead/behind as expected

Example Use Cases

  • Creating feature branches from main to implement a user-facing enhancement (e.g., feature/profile-ui) after a branch status check confirms a clean working directory
  • Branching for a hotfix from a stable release base (e.g., origin/release-2.0) to isolate urgent fixes
  • Resolving a branch-related error by attempting to create a new branch with a unique name when the desired branch already exists
  • Synchronizing with the remote to ensure the new branch is based on the latest origin/<base-branch> before starting work
  • Generating a completion report that includes current branch name, creation result, and any encountered issues after a branching operation

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers