managing-branches
Scannednpx machina-cli add skill aiskillstore/marketplace/managing-branches --openclawBranch 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
| Error | Action |
|---|---|
| Branch exists | Report to user, suggest alternative or confirm use existing |
| Uncommitted changes | git stash or commit first |
| Remote sync error | git fetch --all retry |
| Permission error | Report to user |
Conflict Resolution
git statusto identify conflicts- Resolve each file
git add <resolved-file>- 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) 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) Decide on a base-branch and the new-branch name you want to create
- 3) Create the new branch from origin/<base-branch>: git fetch origin <base-branch>; git checkout -b <new-branch> origin/<base-branch>
- 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