Git Environment

Automates git worktree creation, branching, committing, and pushing for HyperShift development workflows.

538|560|Updated Jan 18, 2021
One-click install
npx skills add https://github.com/openshift/hypershift --skill git-environment
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Git Environment
Source: https://github.com/openshift/hypershift/tree/main/.claude/skills/dev/git-env
Command: npx skills add https://github.com/openshift/hypershift --skill git-environment

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Setting up isolated development environments and following consistent git workflows in the HyperShift repository requires repetitive manual commands for worktrees, branch naming, commit formatting, and remote synchronization, which is error-prone and slow.

Core Features & Use Cases

  • Worktree-Based Environments: Create parallel development environments with git worktree add so multiple features can be developed side by side in the same repository.
  • Standardized Branching and Commits: Enforces conventional branch prefixes (feat/, fix/, docs/) and commit message format with Signed-off-by trailers, validated via make run-gitlint.
  • Remote Sync and Cleanup: Handles pushing to a fork remote, rebasing on upstream main with safe --force-with-lease, and cleaning up worktrees after merge.
  • Use Case: A developer starting a new AWS PrivateLink feature runs the workflow to fetch upstream main, create a worktree with a feat/ branch, commit changes in the required format, push to their fork, and open a PR with gh.

Quick Start

Ask the assistant to create a new git worktree and feature branch from upstream main for your HyperShift change, then commit and push it to your fork.

Frequently Asked Questions about Git Environment

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a git worktree with a new branch?

Run git fetch on the upstream remote, then use git worktree add -b <branch-name> <path> upstream/main. This creates a new branch in a separate working directory sharing the same repository, enabling parallel development.

How to push a branch to a fork remote for the first time?

Use git push -u <fork-remote> <branch-name> to set the upstream tracking reference on the first push. Subsequent pushes only require git push, and after a rebase use git push --force-with-lease for safety.

What commit message format does HyperShift require?

Commits follow the conventional format type(scope): description, with a Signed-off-by trailer and a Commit-Message-Assisted-by line when applicable. Validate the message by running make run-gitlint before pushing.

Why use --force-with-lease instead of --force when pushing?

The --force-with-lease flag refuses to overwrite remote refs that have changed since your last fetch, preventing accidental loss of others' commits. It is required after rebasing a branch onto updated upstream main.

How do I clean up a git worktree after a PR is merged?

Run git worktree remove <path> to delete the working directory, then git branch -D <branch> to delete the local branch. Use git worktree prune to clear stale worktree references.