Git Mastery - Complete Git Expertise
Comprehensive Git skill covering basic to advanced operations, with mandatory safety guardrails for destructive commands and platform-specific workflows.
Critical Guidelines
Windows File Path Requirements
When using Edit or Write tools on Windows, use backslashes (\) in file paths, NOT forward slashes (/):
- WRONG:
D:/repos/project/file.tsx
- CORRECT:
D:\repos\project\file.tsx
Applies to: Edit/Write file_path parameters and all file operations.
Documentation Guidelines
NEVER create new documentation files unless explicitly requested by the user. Prefer updating existing README.md files. Keep documentation concise, direct, and professional.
TL;DR Safety First
Before ANY destructive operation:
# ALWAYS check status first
git status
git log --oneline -10
# For risky operations, create a safety branch
git branch backup-$(date +%Y%m%d-%H%M%S)
# Remember: git reflog is your safety net (90 days default)
git reflog
User Preference Check (ALWAYS ASK at start of any Git task):
"Would you like me to:
- Create commits automatically with appropriate messages
- Stage changes only (you handle commits manually)
- Just provide guidance (no automatic operations)"
Respect this choice throughout the session.
When to Use This Skill
Activate for ANY Git command or operation including:
- Repository initialization, cloning, configuration
- Branch management and strategies
- Commit workflows and best practices
- Merge strategies and conflict resolution
- Rebase operations (interactive and non-interactive)
- History rewriting (filter-repo, reset, revert)
- Recovery operations (reflog, fsck)
- Dangerous operations (force push, hard reset)
- Platform-specific workflows (GitHub, Azure DevOps, Bitbucket, GitLab)
- Advanced features (submodules, worktrees, hooks)
- Performance optimization, large files (LFS)
- Cross-platform compatibility (Windows/Linux/macOS)
Key indicators: user mentions Git, GitHub, GitLab, Bitbucket, Azure DevOps, version control, commit/push/pull/merge/rebase, branch management, history modification, or recovery scenarios.
Core Principles
1. Safety Guardrails for Destructive Operations
Before ANY destructive operation (reset --hard, force push, filter-repo, etc.):
- Always warn the user explicitly
- Explain the risks clearly
- Ask for confirmation
- Suggest creating a backup branch first
- Provide recovery instructions
See references/dangerous-operations.md for full safety protocols and confirmation scripts.
2. Commit Creation Policy
ALWAYS ask the user preference at the start of any Git task (automatic / stage-only / guidance-only). Respect this choice throughout.
3. Platform Awareness
Git behavior differs across platforms and hosting providers:
- Windows (Git Bash/PowerShell): Line endings (
core.autocrlf), path separators, case sensitivity, Windows Credential Manager
- Linux/macOS: Case-sensitive filesystems, SSH key management, permissions
- Hosting platforms: GitHub (PRs, Actions,
gh CLI), Azure DevOps (PRs, Pipelines, policies), Bitbucket (PRs, Pipelines, Jira), GitLab (MRs, CI/CD)
See references/platform-workflows.md for hosting-specific commands and references/cross-platform.md for Windows/Linux/macOS handling.
Reference Map
This SKILL.md is a lean orchestrator. Detailed command catalogs and procedures live in references/:
| Reference |
Contents |
references/basic-operations.md |
Init, clone, config, basic workflow, branches, remotes, fetch/pull/push (non-destructive) |
references/merging-rebasing.md |
Merge strategies, conflict resolution, rebase (interactive/onto/autosquash), cherry-pick |
references/advanced-commands.md |
Stash (incl. Git 2.51+ import/export), revert, reflog, bisect, clean, worktrees, submodules, tags |
references/dangerous-operations.md |
Reset (hard/soft/mixed), force push, filter-repo, amend pushed commits, safety protocols |
references/platform-workflows.md |
GitHub, Azure DevOps, Bitbucket, GitLab CLIs and CI/CD templates |
references/performance-large-files.md |
GC, repack, fsck, LFS, shallow clones, large-file discovery |
references/hooks-and-security.md |
Client/server hooks, credential management, SSH, GPG, secret prevention, conventional commits |
references/troubleshooting-recovery.md |
Common problems, recovery scenarios, emergency commands |
references/cross-platform.md |
Line endings, case sensitivity, Git Bash/MINGW path conversion, shell detection |
Quick Command Index
| Task |
Reference |
git init, git clone, git add, git commit, git log, git diff |
basic-operations |
git branch, git switch, git remote, git fetch, git pull, git push |
basic-operations |
git merge, conflict markers, git rebase -i, git cherry-pick |
merging-rebasing |
git stash, git revert, git reflog, git bisect, git clean, git worktree, git submodule, git tag |
advanced-commands |
git reset --hard, git push --force[-with-lease], git filter-repo, amend pushed |
dangerous-operations |
gh pr, az repos pr, bb pr, glab mr, CI/CD YAML |
platform-workflows |
git gc, git repack, git lfs, shallow clone |
performance-large-files |
.git/hooks/*, conventional commits, SSH/GPG/secrets |
hooks-and-security |
| Detached HEAD, recover branch/file/commit, corrupted repo |
troubleshooting-recovery |
core.autocrlf, core.ignorecase, MSYS_NO_PATHCONV, cygpath, $MSYSTEM |
cross-platform |
Success Criteria
A Git workflow using this skill should:
- ALWAYS ask user preference for automatic commits vs manual
- ALWAYS warn before destructive operations
- ALWAYS create backup branches before risky operations
- ALWAYS explain recovery procedures
- Use appropriate branch strategy for the project
- Write meaningful commit messages
- Keep commit history clean and linear
- Never commit secrets or large binary files
- Test code before committing
- Know how to recover from any mistake
Closing Note
Combined with the reference files and safety guardrails, this skill provides the knowledge to handle ANY Git operation safely and effectively. Always load the appropriate reference before executing a category of commands.
1---
2name: git-master
3description: |
4 Complete Git expertise system for ALL git operations.
5 PROACTIVELY activate for: (1) ANY Git task (basic/advanced/dangerous), (2) Repository management, (3) Branch strategies and workflows, (4) Conflict resolution, (5) History rewriting/recovery, (6) Platform-specific operations (GitHub/Azure DevOps/Bitbucket), (7) Advanced commands (rebase/cherry-pick/filter-repo).
6 Provides: complete Git command reference, safety guardrails for destructive operations, platform best practices, workflow strategies, reflog recovery techniques, and expert guidance for even the most risky operations.
7 Always asks user preference for automatic commits vs manual control.
8metadata:
9 source: https://skillmd.com/skills/josiahsiegel/git-master
10---
11
12# Git Mastery - Complete Git Expertise
13
14Comprehensive Git skill covering basic to advanced operations, with mandatory safety guardrails for destructive commands and platform-specific workflows.
15
16## Critical Guidelines
17
18### Windows File Path Requirements
19
20When using Edit or Write tools on Windows, use backslashes (`\`) in file paths, NOT forward slashes (`/`):
21
22- WRONG: `D:/repos/project/file.tsx`
23- CORRECT: `D:\repos\project\file.tsx`
24
25Applies to: Edit/Write `file_path` parameters and all file operations.
26
27### Documentation Guidelines
28
29NEVER create new documentation files unless explicitly requested by the user. Prefer updating existing README.md files. Keep documentation concise, direct, and professional.
30
31## TL;DR Safety First
32
33Before ANY destructive operation:
34
35```bash
36# ALWAYS check status first
37git status
38git log --oneline -10
39
40# For risky operations, create a safety branch
41git branch backup-$(date +%Y%m%d-%H%M%S)
42
43# Remember: git reflog is your safety net (90 days default)
44git reflog
45```
46
47**User Preference Check (ALWAYS ASK at start of any Git task):**
48
49"Would you like me to:
501. Create commits automatically with appropriate messages
512. Stage changes only (you handle commits manually)
523. Just provide guidance (no automatic operations)"
53
54Respect this choice throughout the session.
55
56## When to Use This Skill
57
58Activate for ANY Git command or operation including:
59
60- Repository initialization, cloning, configuration
61- Branch management and strategies
62- Commit workflows and best practices
63- Merge strategies and conflict resolution
64- Rebase operations (interactive and non-interactive)
65- History rewriting (filter-repo, reset, revert)
66- Recovery operations (reflog, fsck)
67- Dangerous operations (force push, hard reset)
68- Platform-specific workflows (GitHub, Azure DevOps, Bitbucket, GitLab)
69- Advanced features (submodules, worktrees, hooks)
70- Performance optimization, large files (LFS)
71- Cross-platform compatibility (Windows/Linux/macOS)
72
73**Key indicators:** user mentions Git, GitHub, GitLab, Bitbucket, Azure DevOps, version control, commit/push/pull/merge/rebase, branch management, history modification, or recovery scenarios.
74
75## Core Principles
76
77### 1. Safety Guardrails for Destructive Operations
78
79Before ANY destructive operation (`reset --hard`, force push, `filter-repo`, etc.):
80
811. Always warn the user explicitly
822. Explain the risks clearly
833. Ask for confirmation
844. Suggest creating a backup branch first
855. Provide recovery instructions
86
87See `references/dangerous-operations.md` for full safety protocols and confirmation scripts.
88
89### 2. Commit Creation Policy
90
91ALWAYS ask the user preference at the start of any Git task (automatic / stage-only / guidance-only). Respect this choice throughout.
92
93### 3. Platform Awareness
94
95Git behavior differs across platforms and hosting providers:
96
97- **Windows (Git Bash/PowerShell):** Line endings (`core.autocrlf`), path separators, case sensitivity, Windows Credential Manager
98- **Linux/macOS:** Case-sensitive filesystems, SSH key management, permissions
99- **Hosting platforms:** GitHub (PRs, Actions, `gh` CLI), Azure DevOps (PRs, Pipelines, policies), Bitbucket (PRs, Pipelines, Jira), GitLab (MRs, CI/CD)
100
101See `references/platform-workflows.md` for hosting-specific commands and `references/cross-platform.md` for Windows/Linux/macOS handling.
102
103## Reference Map
104
105This SKILL.md is a lean orchestrator. Detailed command catalogs and procedures live in `references/`:
106
107| Reference | Contents |
108|-----------|----------|
109| `references/basic-operations.md` | Init, clone, config, basic workflow, branches, remotes, fetch/pull/push (non-destructive) |
110| `references/merging-rebasing.md` | Merge strategies, conflict resolution, rebase (interactive/onto/autosquash), cherry-pick |
111| `references/advanced-commands.md` | Stash (incl. Git 2.51+ import/export), revert, reflog, bisect, clean, worktrees, submodules, tags |
112| `references/dangerous-operations.md` | Reset (hard/soft/mixed), force push, filter-repo, amend pushed commits, safety protocols |
113| `references/platform-workflows.md` | GitHub, Azure DevOps, Bitbucket, GitLab CLIs and CI/CD templates |
114| `references/performance-large-files.md` | GC, repack, fsck, LFS, shallow clones, large-file discovery |
115| `references/hooks-and-security.md` | Client/server hooks, credential management, SSH, GPG, secret prevention, conventional commits |
116| `references/troubleshooting-recovery.md` | Common problems, recovery scenarios, emergency commands |
117| `references/cross-platform.md` | Line endings, case sensitivity, Git Bash/MINGW path conversion, shell detection |
118
119## Quick Command Index
120
121| Task | Reference |
122|------|-----------|
123| `git init`, `git clone`, `git add`, `git commit`, `git log`, `git diff` | basic-operations |
124| `git branch`, `git switch`, `git remote`, `git fetch`, `git pull`, `git push` | basic-operations |
125| `git merge`, conflict markers, `git rebase -i`, `git cherry-pick` | merging-rebasing |
126| `git stash`, `git revert`, `git reflog`, `git bisect`, `git clean`, `git worktree`, `git submodule`, `git tag` | advanced-commands |
127| `git reset --hard`, `git push --force[-with-lease]`, `git filter-repo`, amend pushed | dangerous-operations |
128| `gh pr`, `az repos pr`, `bb pr`, `glab mr`, CI/CD YAML | platform-workflows |
129| `git gc`, `git repack`, `git lfs`, shallow clone | performance-large-files |
130| `.git/hooks/*`, conventional commits, SSH/GPG/secrets | hooks-and-security |
131| Detached HEAD, recover branch/file/commit, corrupted repo | troubleshooting-recovery |
132| `core.autocrlf`, `core.ignorecase`, `MSYS_NO_PATHCONV`, `cygpath`, `$MSYSTEM` | cross-platform |
133
134## Success Criteria
135
136A Git workflow using this skill should:
137
1381. ALWAYS ask user preference for automatic commits vs manual
1392. ALWAYS warn before destructive operations
1403. ALWAYS create backup branches before risky operations
1414. ALWAYS explain recovery procedures
1425. Use appropriate branch strategy for the project
1436. Write meaningful commit messages
1447. Keep commit history clean and linear
1458. Never commit secrets or large binary files
1469. Test code before committing
14710. Know how to recover from any mistake
148
149## Closing Note
150
151Combined with the reference files and safety guardrails, this skill provides the knowledge to handle ANY Git operation safely and effectively. Always load the appropriate reference before executing a category of commands.