git-advanced
??ベース、チェリーピック、バイセクト、リフロッグ、コミットの復元など、Gitの高度な操作を効率的に実行するためのSkillです。
📜 元の英語説明(参考)
Advanced Git operations including rebase, cherry-pick, bisect, reflog, and recovery. Use when user asks to "rebase branch", "cherry-pick commit", "find bug with bisect", "recover lost commit", "squash commits", "fix git history", "interactive rebase", or any advanced git tasks.
🇯🇵 日本人クリエイター向け解説
??ベース、チェリーピック、バイセクト、リフロッグ、コミットの復元など、Gitの高度な操作を効率的に実行するためのSkillです。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o git-advanced.zip https://jpskill.com/download/6089.zip && unzip -o git-advanced.zip && rm git-advanced.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6089.zip -OutFile "$d\git-advanced.zip"; Expand-Archive "$d\git-advanced.zip" -DestinationPath $d -Force; ri "$d\git-advanced.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
git-advanced.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
git-advancedフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Git Advanced
高度なGit操作とリカバリ技術です。
インタラクティブなリベース
# 最後のN個のコミットをリベースします
git rebase -i HEAD~5
# ブランチにリベースします
git rebase -i main
# インタラクティブエディタでのコマンド:
# pick = コミットをそのまま保持します
# reword = コミットを保持し、メッセージを編集します
# edit = 修正のために一時停止します
# squash = 前のコミットと結合します
# fixup = 前のコミットと結合し、メッセージを破棄します
# drop = コミットを削除します
# 最後の3つのコミットを1つにスカッシュします
git rebase -i HEAD~3
# 2番目と3番目のコミットの 'pick' を 'squash' に変更します
# 何か問題が発生した場合は中止します
git rebase --abort
# 競合を解決した後、続行します
git rebase --continue
# 現在のコミットをスキップします
git rebase --skip
チェリーピック
# 単一のコミットを選択します
git cherry-pick abc1234
# コミットの範囲を選択します
git cherry-pick abc1234..def5678
# コミットせずに選択します (ステージのみ)
git cherry-pick --no-commit abc1234
# 別のブランチから選択します
git cherry-pick feature-branch~3 # 先頭から3番目のコミット
# 競合を解決して続行します
git cherry-pick --continue
# 中止します
git cherry-pick --abort
バイセクト
# バイセクトを開始します
git bisect start
# 現在のコミットを不良としてマークします
git bisect bad
# 既知の良好なコミットをマークします
git bisect good v1.0.0
# Gitは中間のコミットをチェックアウトします - テストしてから、以下を実行します:
git bisect good # このコミットが動作する場合
git bisect bad # このコミットが壊れている場合
# Gitが原因を見つけるまで繰り返します
# バイセクトを終了します
git bisect reset
# テストコマンドを使用した自動バイセクト
git bisect start HEAD v1.0.0
git bisect run npm test
# Gitは最初の不良コミットを自動的に見つけます
# スクリプトを使用した自動化
git bisect run ./test-script.sh
# スクリプトは0 (良好) または1 (不良) で終了する必要があります
スタッシュ
# 作業中の変更を保存します
git stash
git stash push -m "work on feature X"
# 特定のファイルをスタッシュします
git stash push -m "partial" path/to/file.js
# 未追跡ファイルを含めます
git stash -u
git stash --include-untracked
# スタッシュを一覧表示します
git stash list
# スタッシュを適用します
git stash pop # 適用して削除します
git stash apply # 適用して保持します
git stash pop stash@{2} # 特定のスタッシュ
# スタッシュの内容を表示します
git stash show -p stash@{0}
# スタッシュからブランチを作成します
git stash branch new-branch stash@{0}
# スタッシュを削除します
git stash drop stash@{0}
git stash clear # すべてのスタッシュを削除します
Reflog (リカバリ)
# リフロッグを表示します
git reflog
git reflog show HEAD
git reflog show main
# 各エントリはその時点でのHEADの位置を示します
# HEAD@{0} = 現在
# HEAD@{1} = 以前の位置
# ハードリセット後のリカバリ
git reflog
# リセット前のコミットハッシュを見つけます
git reset --hard HEAD@{2}
# 削除されたブランチのリカバリ
git reflog
# 削除されたブランチの最後のコミットを見つけます
git checkout -b recovered-branch abc1234
# 不良なリベース後のリカバリ
git reflog
# リベース開始前のコミットを見つけます
git reset --hard HEAD@{5}
# リフロッグは90日後に期限切れになります (デフォルト)
Reset と Revert
# Reset (HEADを移動し、履歴を書き換えます)
git reset --soft HEAD~1 # コミットを取り消し、変更をステージングされたままにします
git reset --mixed HEAD~1 # コミットを取り消し、変更をステージングされていないままにします (デフォルト)
git reset --hard HEAD~1 # コミットを取り消し、変更を破棄します
# Revert (新しいコミットを作成し、共有ブランチに安全です)
git revert abc1234
git revert HEAD~3..HEAD # 範囲をリバートします
git revert --no-commit abc1234 # コミットせずにステージングします
# マージコミットをリバートします
git revert -m 1 abc1234 # 親1 (通常はmain) を保持します
ワークツリー
# リンクされたワークツリーを作成します
git worktree add ../project-hotfix hotfix-branch
git worktree add ../project-review origin/feature-branch
# ワークツリーを一覧表示します
git worktree list
# ワークツリーを削除します
git worktree remove ../project-hotfix
# 古いワークツリーを整理します
git worktree prune
ログと履歴
# コンパクトなログ
git log --oneline --graph --all
# メッセージでコミットを検索します
git log --grep="fix bug"
# コード変更でコミットを検索します
git log -S "functionName" # ピッケル (追加/削除されたもの)
git log -G "pattern" # diff内の正規表現
# ファイルを変更したコミットを表示します
git log --follow -- path/to/file.js
# 各行を変更した人を表示します
git blame path/to/file.js
git blame -L 10,20 path/to/file.js # 10行目から20行目
# ブランチ間の差分
git diff main..feature
git diff main...feature # フォークポイントからの変更
# コミット間で変更されたファイルを表示します
git diff --name-only HEAD~5 HEAD
クリーンアップ
# 未追跡ファイルを削除します (最初にドライラン!)
git clean -n # プレビュー
git clean -f # ファイルを削除します
git clean -fd # ファイルとディレクトリを削除します
git clean -fx # 無視されたファイルも削除します
# ガベージコレクション
git gc
git gc --aggressive
# 古いリフロッグエントリを削除します
git reflog expire --expire=30.days --all
一般的なワークフロー
# スカッシュマージ (クリーンな履歴)
git checkout main
git merge --squash feature-branch
git commit -m "Add feature X"
# マージ前のリベース (線形履歴)
git checkout feature
git rebase main
git checkout main
git merge feature # ファストフォワード
# Fixupワークフロー
git commit --fixup=abc1234
git rebase -i --autosquash main
参照
リカバリ技術とリフロッグパターンについては: references/recovery.md
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Git Advanced
Advanced Git operations and recovery techniques.
Interactive Rebase
# Rebase last N commits
git rebase -i HEAD~5
# Rebase onto branch
git rebase -i main
# Commands in interactive editor:
# pick = keep commit as-is
# reword = keep commit, edit message
# edit = pause for amending
# squash = combine with previous commit
# fixup = combine with previous, discard message
# drop = remove commit
# Squash last 3 commits into one
git rebase -i HEAD~3
# Change 'pick' to 'squash' for commits 2 and 3
# Abort if something goes wrong
git rebase --abort
# Continue after resolving conflicts
git rebase --continue
# Skip current commit
git rebase --skip
Cherry-Pick
# Pick single commit
git cherry-pick abc1234
# Pick range of commits
git cherry-pick abc1234..def5678
# Pick without committing (stage only)
git cherry-pick --no-commit abc1234
# Pick from another branch
git cherry-pick feature-branch~3 # 3rd commit from tip
# Resolve conflicts and continue
git cherry-pick --continue
# Abort
git cherry-pick --abort
Bisect
# Start bisect
git bisect start
# Mark current as bad
git bisect bad
# Mark known good commit
git bisect good v1.0.0
# Git checks out middle commit - test it, then:
git bisect good # If this commit works
git bisect bad # If this commit is broken
# Repeat until Git finds the culprit
# End bisect
git bisect reset
# Automated bisect with test command
git bisect start HEAD v1.0.0
git bisect run npm test
# Git automatically finds the first bad commit
# Automated with script
git bisect run ./test-script.sh
# Script must exit 0 (good) or 1 (bad)
Stash
# Save work in progress
git stash
git stash push -m "work on feature X"
# Stash specific files
git stash push -m "partial" path/to/file.js
# Include untracked files
git stash -u
git stash --include-untracked
# List stashes
git stash list
# Apply stash
git stash pop # Apply and remove
git stash apply # Apply and keep
git stash pop stash@{2} # Specific stash
# View stash contents
git stash show -p stash@{0}
# Create branch from stash
git stash branch new-branch stash@{0}
# Drop stash
git stash drop stash@{0}
git stash clear # Remove all stashes
Reflog (Recovery)
# View reflog
git reflog
git reflog show HEAD
git reflog show main
# Each entry shows HEAD position at that point
# HEAD@{0} = current
# HEAD@{1} = previous position
# Recover after hard reset
git reflog
# Find the commit hash before the reset
git reset --hard HEAD@{2}
# Recover deleted branch
git reflog
# Find last commit of deleted branch
git checkout -b recovered-branch abc1234
# Recover after bad rebase
git reflog
# Find the commit before rebase started
git reset --hard HEAD@{5}
# Reflog expires after 90 days (default)
Reset vs Revert
# Reset (moves HEAD, rewrites history)
git reset --soft HEAD~1 # Undo commit, keep changes staged
git reset --mixed HEAD~1 # Undo commit, keep changes unstaged (default)
git reset --hard HEAD~1 # Undo commit, discard changes
# Revert (creates new commit, safe for shared branches)
git revert abc1234
git revert HEAD~3..HEAD # Revert range
git revert --no-commit abc1234 # Stage without committing
# Revert a merge commit
git revert -m 1 abc1234 # Keep parent 1 (usually main)
Worktrees
# Create linked worktree
git worktree add ../project-hotfix hotfix-branch
git worktree add ../project-review origin/feature-branch
# List worktrees
git worktree list
# Remove worktree
git worktree remove ../project-hotfix
# Prune stale worktrees
git worktree prune
Log & History
# Compact log
git log --oneline --graph --all
# Search commits by message
git log --grep="fix bug"
# Search commits by code change
git log -S "functionName" # Pickaxe (added/removed)
git log -G "pattern" # Regex in diff
# Show commits that changed a file
git log --follow -- path/to/file.js
# Show who changed each line
git blame path/to/file.js
git blame -L 10,20 path/to/file.js # Lines 10-20
# Diff between branches
git diff main..feature
git diff main...feature # Changes since fork point
# Show files changed between commits
git diff --name-only HEAD~5 HEAD
Cleanup
# Remove untracked files (dry run first!)
git clean -n # Preview
git clean -f # Delete files
git clean -fd # Delete files and directories
git clean -fx # Delete ignored files too
# Garbage collection
git gc
git gc --aggressive
# Remove old reflog entries
git reflog expire --expire=30.days --all
Common Workflows
# Squash merge (clean history)
git checkout main
git merge --squash feature-branch
git commit -m "Add feature X"
# Rebase before merge (linear history)
git checkout feature
git rebase main
git checkout main
git merge feature # Fast-forward
# Fixup workflow
git commit --fixup=abc1234
git rebase -i --autosquash main
Reference
For recovery techniques and reflog patterns: references/recovery.md