本文へスキップ
Skillpedia
一般的なプログラミング48k · #4733

git-advanced-workflows

できること

このツールは、プロジェクトの履歴を整理・整頓し、エラーを素早く見つけ、複数の作業を迷わず同時に進めるのに役立ちます。

使う場面

  • ✓変更を提出する前に、内容を整理したいとき
  • ✓問題の原因となった変更を見つけたいとき
  • ✓複数のタスクを同時に進めたいとき

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/git-advanced-workflows/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/git-advanced-workflows/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“直近5つのコミットの履歴を整理して、メッセージをまとめたり、一部の変更を統合したりするにはどうすればいいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

高度なGitコマンドを使って履歴を書き換えたり、プロジェクト間で特定の変更を適用したり、古いバージョンのエラーを探したりします。これにより、より整理された、わかりやすい記録を残せます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Git Advanced Workflows

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

Do not use this skill when

  • The task is unrelated to git advanced workflows
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.

When to Use

  • Cleaning up commit history before merging
  • Applying specific commits across branches
  • Finding commits that introduced bugs
  • Working on multiple features simultaneously
  • Recovering from Git mistakes or lost commits
  • Managing complex branch workflows
  • Preparing clean PRs for review
  • Synchronizing diverged branches

Repository and Recovery Boundary

Read repository instructions and branch protection first. A hotfix follows the protected PR/maintainer path when required; urgency does not authorize a direct default-branch commit or push. Preserve dirty and staged work before checkout, rebase, reset or restore. A backup branch protects committed history only, not uncommitted files. Inspect exact targets before destructive operations and obtain authorization for shared-history rewrites. Reflog availability depends on local expiry and garbage collection; it cannot guarantee recovery of every lost file.

Core Concepts

1. Interactive Rebase

Interactive rebase is the Swiss Army knife of Git history editing.

Common Operations:

  • pick: Keep commit as-is
  • reword: Change commit message
  • edit: Amend commit content
  • squash: Combine with previous commit
  • fixup: Like squash but discard message
  • drop: Remove commit entirely

Basic Usage:

# Rebase last 5 commits
git rebase -i HEAD~5

# Rebase all commits on current branch
git rebase -i $(git merge-base HEAD main)

# Rebase onto specific commit
git rebase -i abc123

2. Cherry-Picking

Apply specific commits from one branch to another without merging entire branches.

# Cherry-pick single commit
git cherry-pick abc123

# Cherry-pick range of commits (exclusive start)
git cherry-pick abc123..def456

# Cherry-pick without committing (stage changes only)
git cherry-pick -n abc123

# Cherry-pick and edit commit message
git cherry-pick -e abc123

3. Git Bisect

Binary search through commit history to find the commit that introduced a bug.

# Start bisect
git bisect start

# Mark current commit as bad
git bisect bad

# Mark known good commit
git bisect good v1.0.0

# Git will checkout middle commit - test it
# Then mark as good or bad
git bisect good  # or: git bisect bad

# Continue until bug found
# When done
git bisect reset

Automated Bisect:

# Use script to test automatically
git bisect start HEAD v1.0.0
git bisect run ./test.sh

# test.sh should exit 0 for good, 1-127 (except 125) for bad

4. Worktrees

Work on multiple branches simultaneously without stashing or switching.

# List existing worktrees
git worktree list

# Add new worktree for feature branch
git worktree add ../project-feature feature/new-feature

# Add worktree and create new branch
git worktree add -b bugfix/urgent ../project-hotfix main

# Remove worktree
git worktree remove ../project-feature

# Prune stale worktrees
git worktree prune

5. Reflog

Your safety net - tracks all ref movements, even deleted commits.

# View reflog
git reflog

# View reflog for specific branch
git reflog show feature/branch

# Restore deleted commit
git reflog
# Find commit hash
git checkout abc123
git branch recovered-branch

# Restore deleted branch
git reflog
git branch deleted-branch abc123

Practical Workflows

Workflow 1: Clean Up Feature Branch Before PR

# Start with feature branch
git checkout feature/user-auth

# Interactive rebase to clean history
git rebase -i main

# Example rebase operations:
# - Squash "fix typo" commits
# - Reword commit messages for clarity
# - Reorder commits logically
# - Drop unnecessary commits

# Force push cleaned branch (safe if no one else is using it)
git push --force-with-lease origin feature/user-auth

Workflow 2: Apply Hotfix to Multiple Releases

# Create fix on an authorized topic branch from the current target
git fetch origin main
git switch -c hotfix/security origin/main
git commit -m "fix: critical security patch"

# Apply to release branches

…
よくある質問

「インタラクティブリベース」とは何ですか?

他の人に見られる前にコミット(保存された変更)を編集・並べ替えする方法です。複数のコミットをまとめたり、名前を変えたり、削除したりできます。

「チェリーピック」とは何ですか?

プロジェクトの中で、特定の変更だけを別の場所にコピーすることです。他の変更をまとめて移動させる必要はありません。

「git bisect」とは何ですか?

プロジェクトの履歴を効率よく検索して、どの変更がエラーやバグを引き起こしたのかを正確に見つけるためのツールです。

詳細

作者による元の説明

Master advanced Git techniques to maintain clean history, collaborate effectively, and recover from any situation with confidence.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4733
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル