git-patch-workflow
Creating, managing, and applying unified diff patches with Git for source code modifications.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 92
- Forks
- 7
01 前言 Front Matter
- name
- git-patch-workflow
- description
- Creating, managing, and applying unified diff patches with Git for source code modifications.
03 SKILL.md 正文
Git Patch Workflow
Creating Patch Files
Method 1: From Unstaged Changes
cd /path/to/repo
git diff path/to/file.java > /path/to/patch/fix.patch
Method 2: From Staged Changes
git diff --cached > /path/to/patch/fix.patch
Method 3: From Commits
# Create patch from last N commits
git format-patch -N HEAD
# Create patch from specific commit
git show COMMIT_HASH > /path/to/patch/fix.patch
Patch File Structure
A unified diff patch looks like:
--- a/original/path/file.java
+++ b/modified/path/file.java
@@ -10,5 +10,6 @@ class MyClass {
// context line
- old code here
+ new code here
// context line
Key components:
---prefix: original file+++prefix: modified file@@markers: line numbers and context-prefix: removed lines+prefix: added lines- No prefix: context lines
Applying Patches
Basic Application
cd /path/to/repo
patch -p1 < /path/to/patch/fix.patch
With Error Handling
# Dry-run to test application
patch -p1 --dry-run < /path/to/patch/fix.patch
# Apply with strict checking
patch -p1 < /path/to/patch/fix.patch
# Apply with less strict checking
patch -p0 < /path/to/patch/fix.patch
Best Practices
- Use Git Format: Create patches via
git difforgit format-patchfor consistency - Include Context: Ensure adequate context lines (3+ lines around changes)
- Test Patches: Always dry-run before applying to ensure compatibility
- Modular Patches: Create separate patches for logically independent changes
- Clear Names: Name patches descriptively (e.g.,
fix-javascript-security-bypass.patch) - Document Changes: Include explanation of what the patch fixes
Verifying Application
# Check if patch was applied
git status
git diff HEAD
# Verify specific file was patched
git show HEAD:path/to/file.java | grep "your fix"
Multiple Patches
For multiple related patches:
# Create patches in order
git diff HEAD~2 HEAD~1 > patch1.patch
git diff HEAD~1 HEAD > patch2.patch
# Apply in sequence
patch -p1 < patch1.patch
patch -p1 < patch2.patch
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.