🛠️ Git Essentials
Gitの基本的なコマンドやワークフローを使い、バージョン管理、ブランチ作成、チームでの共同作業を円滑に進めるための、ビジネスシーンで必須となるGit操作を習得するSkill。
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
Essential Git commands and workflows for version control, branching, and collaboration.
🇯🇵 日本人クリエイター向け解説
Gitの基本的なコマンドやワークフローを使い、バージョン管理、ブランチ作成、チームでの共同作業を円滑に進めるための、ビジネスシーンで必須となるGit操作を習得するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o git-essentials.zip https://jpskill.com/download/4860.zip && unzip -o git-essentials.zip && rm git-essentials.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/4860.zip -OutFile "$d\git-essentials.zip"; Expand-Archive "$d\git-essentials.zip" -DestinationPath $d -Force; ri "$d\git-essentials.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
git-essentials.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
git-essentialsフォルダができる - 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-18
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › Git Essentials を使って、最小構成のサンプルコードを示して
- › Git Essentials の主な使い方と注意点を教えて
- › Git Essentials を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Gitの基本
バージョン管理と共同作業のための必須Gitコマンドです。
初期設定
# ユーザー設定
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
# リポジトリの初期化
git init
# リポジトリのクローン
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git custom-name
基本的なワークフロー
ステージングとコミット
# ステータスの確認
git status
# ファイルをステージングに追加
git add file.txt
git add .
git add -A # 削除を含むすべての変更
# 変更をコミット
git commit -m "Commit message"
# 追加とコミットを一度に実行
git commit -am "Message"
# 直前のコミットを修正
git commit --amend -m "New message"
git commit --amend --no-edit # メッセージを保持
変更の表示
# ステージされていない変更を表示
git diff
# ステージされた変更を表示
git diff --staged
# 特定のファイルの変更を表示
git diff file.txt
# コミット間の変更を表示
git diff commit1 commit2
ブランチとマージ
ブランチ管理
# ブランチの一覧表示
git branch
git branch -a # リモートブランチを含む
# ブランチの作成
git branch feature-name
# ブランチの切り替え
git checkout feature-name
git switch feature-name # 現代的な代替手段
# 作成と切り替え
git checkout -b feature-name
git switch -c feature-name
# ブランチの削除
git branch -d branch-name
git branch -D branch-name # 強制削除
# ブランチ名の変更
git branch -m old-name new-name
マージ
# ブランチを現在のブランチにマージ
git merge feature-name
# fast-forwardなしでマージ
git merge --no-ff feature-name
# マージを中止
git merge --abort
# マージの競合を表示
git diff --name-only --diff-filter=U
リモート操作
リモートの管理
# リモートの一覧表示
git remote -v
# リモートの追加
git remote add origin https://github.com/user/repo.git
# リモートURLの変更
git remote set-url origin https://github.com/user/new-repo.git
# リモートの削除
git remote remove origin
リモートとの同期
# リモートからフェッチ
git fetch origin
# 変更をプル (フェッチ + マージ)
git pull
# リベースでプル
git pull --rebase
# 変更をプッシュ
git push
# 新しいブランチをプッシュ
git push -u origin branch-name
# 強制プッシュ (注意!)
git push --force-with-lease
履歴とログ
履歴の表示
# コミット履歴の表示
git log
# コミットごとに1行で表示
git log --oneline
# グラフ付きで表示
git log --graph --oneline --all
# 最新N件のコミット
git log -5
# 作者ごとのコミット
git log --author="Name"
# 日付範囲内のコミット
git log --since="2 weeks ago"
git log --until="2024-01-01"
# ファイルの履歴
git log -- file.txt
履歴の検索
# コミットメッセージの検索
git log --grep="bug fix"
# コード変更の検索
git log -S "function_name"
# 各行を変更した人を表示
git blame file.txt
# バグを導入したコミットを検索
git bisect start
git bisect bad
git bisect good commit-hash
変更の取り消し
ワーキングディレクトリ
# ファイルの変更を破棄
git restore file.txt
git checkout -- file.txt # 古い方法
# すべての変更を破棄
git restore .
ステージングエリア
# ファイルのステージを解除
git restore --staged file.txt
git reset HEAD file.txt # 古い方法
# すべてのステージを解除
git reset
コミット
# 直前のコミットを取り消し (変更は保持)
git reset --soft HEAD~1
# 直前のコミットを取り消し (変更は破棄)
git reset --hard HEAD~1
# コミットを元に戻す (新しいコミットを作成)
git revert commit-hash
# 特定のコミットにリセット
git reset --hard commit-hash
スタッシュ
# 変更をスタッシュ
git stash
# メッセージ付きでスタッシュ
git stash save "Work in progress"
# スタッシュの一覧表示
git stash list
# 最新のスタッシュを適用
git stash apply
# スタッシュを適用して削除
git stash pop
# 特定のスタッシュを適用
git stash apply stash@{2}
# スタッシュを削除
git stash drop stash@{0}
# すべてのスタッシュをクリア
git stash clear
リベース
# 現在のブランチをリベース
git rebase main
# 対話型リベース (直近3つのコミット)
git rebase -i HEAD~3
# 競合解決後に続行
git rebase --continue
# 現在のコミットをスキップ
git rebase --skip
# リベースを中止
git rebase --abort
タグ
# タグの一覧表示
git tag
# 軽量タグの作成
git tag v1.0.0
# 注釈付きタグの作成
git tag -a v1.0.0 -m "Version 1.0.0"
# 特定のコミットにタグ付け
git tag v1.0.0 commit-hash
# タグをプッシュ
git push origin v1.0.0
# すべてのタグをプッシュ
git push --tags
# タグの削除
git tag -d v1.0.0
git push origin --delete v1.0.0
高度な操作
チェリーピック
# 特定のコミットを適用
git cherry-pick commit-hash
# コミットせずにチェリーピック
git cherry-pick -n commit-hash
サブモジュール
# サブモジュールの追加
git submodule add https://github.com/user/repo.git path/
# サブモジュールの初期化
git submodule init
# サブモジュールの更新
git submodule update
# サブモジュール付きでクローン
git clone --recursive https://github.com/user/repo.git
クリーン
# 削除されるファイルをプレビュー
git clean -n
# トラッキングされていないファイルを削除
git clean -f
# トラッキングされていないファイルとディレクトリを削除
git clean -fd
# 無視されたファイルを含める
git clean -fdx
一般的なワークフロー
フィーチャーブランチワークフロー:
git checkout -b feature/new-feature
# 変更を加える
git add .
git commit -m "Add new feature"
git push -u origin feature/new-feature
# PRを作成し、マージ後に:
git checkout main
git pull
git branch -d feature/new-feature
ホットフィックスワークフロー:
git checkout main
git pull
git checkout -b hotfix/critical-bug
# バグを修正
git commit -am "Fix critical bug"
git push -u origin hotfix/critical-bug
# マージ後に:
git checkout main && git pull
フォークの同期:
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
便利なエイリアス
~/.gitconfigに追加してください:
[alias]
st = status
co = checkout
br = branch
ci = commit
unstage = reset HEAD --
last = log -1 HEAD
visual = log --graph --oneline --all
amend = commit --amend --no-edit
ヒント
- こまめにコミットし、後で完璧にする
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Git Essentials
Essential Git commands for version control and collaboration.
Initial Setup
# Configure user
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
# Initialize repository
git init
# Clone repository
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git custom-name
Basic Workflow
Staging and committing
# Check status
git status
# Add files to staging
git add file.txt
git add .
git add -A # All changes including deletions
# Commit changes
git commit -m "Commit message"
# Add and commit in one step
git commit -am "Message"
# Amend last commit
git commit --amend -m "New message"
git commit --amend --no-edit # Keep message
Viewing changes
# Show unstaged changes
git diff
# Show staged changes
git diff --staged
# Show changes in specific file
git diff file.txt
# Show changes between commits
git diff commit1 commit2
Branching & Merging
Branch management
# List branches
git branch
git branch -a # Include remote branches
# Create branch
git branch feature-name
# Switch branch
git checkout feature-name
git switch feature-name # Modern alternative
# Create and switch
git checkout -b feature-name
git switch -c feature-name
# Delete branch
git branch -d branch-name
git branch -D branch-name # Force delete
# Rename branch
git branch -m old-name new-name
Merging
# Merge branch into current
git merge feature-name
# Merge with no fast-forward
git merge --no-ff feature-name
# Abort merge
git merge --abort
# Show merge conflicts
git diff --name-only --diff-filter=U
Remote Operations
Managing remotes
# List remotes
git remote -v
# Add remote
git remote add origin https://github.com/user/repo.git
# Change remote URL
git remote set-url origin https://github.com/user/new-repo.git
# Remove remote
git remote remove origin
Syncing with remote
# Fetch from remote
git fetch origin
# Pull changes (fetch + merge)
git pull
# Pull with rebase
git pull --rebase
# Push changes
git push
# Push new branch
git push -u origin branch-name
# Force push (careful!)
git push --force-with-lease
History & Logs
Viewing history
# Show commit history
git log
# One line per commit
git log --oneline
# With graph
git log --graph --oneline --all
# Last N commits
git log -5
# Commits by author
git log --author="Name"
# Commits in date range
git log --since="2 weeks ago"
git log --until="2024-01-01"
# File history
git log -- file.txt
Searching history
# Search commit messages
git log --grep="bug fix"
# Search code changes
git log -S "function_name"
# Show who changed each line
git blame file.txt
# Find commit that introduced bug
git bisect start
git bisect bad
git bisect good commit-hash
Undoing Changes
Working directory
# Discard changes in file
git restore file.txt
git checkout -- file.txt # Old way
# Discard all changes
git restore .
Staging area
# Unstage file
git restore --staged file.txt
git reset HEAD file.txt # Old way
# Unstage all
git reset
Commits
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
# Revert commit (create new commit)
git revert commit-hash
# Reset to specific commit
git reset --hard commit-hash
Stashing
# Stash changes
git stash
# Stash with message
git stash save "Work in progress"
# List stashes
git stash list
# Apply latest stash
git stash apply
# Apply and remove stash
git stash pop
# Apply specific stash
git stash apply stash@{2}
# Delete stash
git stash drop stash@{0}
# Clear all stashes
git stash clear
Rebasing
# Rebase current branch
git rebase main
# Interactive rebase (last 3 commits)
git rebase -i HEAD~3
# Continue after resolving conflicts
git rebase --continue
# Skip current commit
git rebase --skip
# Abort rebase
git rebase --abort
Tags
# List tags
git tag
# Create lightweight tag
git tag v1.0.0
# Create annotated tag
git tag -a v1.0.0 -m "Version 1.0.0"
# Tag specific commit
git tag v1.0.0 commit-hash
# Push tag
git push origin v1.0.0
# Push all tags
git push --tags
# Delete tag
git tag -d v1.0.0
git push origin --delete v1.0.0
Advanced Operations
Cherry-pick
# Apply specific commit
git cherry-pick commit-hash
# Cherry-pick without committing
git cherry-pick -n commit-hash
Submodules
# Add submodule
git submodule add https://github.com/user/repo.git path/
# Initialize submodules
git submodule init
# Update submodules
git submodule update
# Clone with submodules
git clone --recursive https://github.com/user/repo.git
Clean
# Preview files to be deleted
git clean -n
# Delete untracked files
git clean -f
# Delete untracked files and directories
git clean -fd
# Include ignored files
git clean -fdx
Common Workflows
Feature branch workflow:
git checkout -b feature/new-feature
# Make changes
git add .
git commit -m "Add new feature"
git push -u origin feature/new-feature
# Create PR, then after merge:
git checkout main
git pull
git branch -d feature/new-feature
Hotfix workflow:
git checkout main
git pull
git checkout -b hotfix/critical-bug
# Fix bug
git commit -am "Fix critical bug"
git push -u origin hotfix/critical-bug
# After merge:
git checkout main && git pull
Syncing fork:
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
Useful Aliases
Add to ~/.gitconfig:
[alias]
st = status
co = checkout
br = branch
ci = commit
unstage = reset HEAD --
last = log -1 HEAD
visual = log --graph --oneline --all
amend = commit --amend --no-edit
Tips
- Commit often, perfect later (interactive rebase)
- Write meaningful commit messages
- Use
.gitignorefor files to exclude - Never force push to shared branches
- Pull before starting work
- Use feature branches, not main
- Rebase feature branches before merging
- Use
--force-with-leaseinstead of--force
Common Issues
Undo accidental commit:
git reset --soft HEAD~1
Recover deleted branch:
git reflog
git checkout -b branch-name <commit-hash>
Fix wrong commit message:
git commit --amend -m "Correct message"
Resolve merge conflicts:
# Edit files to resolve conflicts
git add resolved-files
git commit # Or git merge --continue
Documentation
Official docs: https://git-scm.com/doc Pro Git book: https://git-scm.com/book Visual Git guide: https://marklodato.github.io/visual-git-guide/