git-workflow
Feature-branch git workflow for agentic coding work: start from a synced main, branch with conventional names, write Conventional Commits, sync with rebase, run the PR lifecycle with gh, and recover safely from mistakes. Use when starting work in a repo, staging or writing commits, rebasing, opening or reviewing PRs, resolving conflicts, or undoing git operations.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- git-workflow
- license
- MIT
- description
- Feature-branch git workflow for agentic coding work: start from a synced main, branch with conventional names, write Conventional Commits, sync with rebase, run the PR lifecycle with gh, and recover safely from mistakes. Use when starting work in a repo, staging or writing commits, rebasing, opening or reviewing PRs, resolving conflicts, or undoing git operations.
- compatibility
- Requires git; gh CLI for the PR sections.
02 资源文件 9
- 参考文档agents/openai.yaml129 B
- 参考文档README.md3.8 KB
- 参考文档references/branching-strategy.md8.9 KB
- 参考文档references/conventional-commits.md3.3 KB
- 参考文档references/git-config.md3.4 KB
- 参考文档references/pr-workflow.md2.4 KB
- 参考文档references/sync-and-recovery.md3.1 KB
- 脚本scripts/check-commit-msg5.0 KB
- 脚本scripts/tests/test_check_commit_msg.py4.3 KB
03 SKILL.md 正文
Git Workflow
Opinionated workflow for git work, synthesized from the user's git cheatsheet,
the asmeurer fork-contribution guide, the netresearch git-workflow skill, and
the Conventional Commits 1.0.0 spec (see README.md, Attribution).
Precedence: the repository's own conventions win. If CONTRIBUTING.md,
AGENTS.md, or a .github/ template specifies branch names, commit format,
merge strategy, or sign-off rules, follow those. Everything here is the
default when the project is silent.
Critical rules
- Never commit to the trunk branch (
main,master, ormainline, whichever the repo uses). Branch for everything, even one-liners. - Always branch from a synced
main: check out main, pull, then create the branch. - Commit messages follow Conventional Commits:
<type>[scope]: <description>. - Sync a feature branch with rebase (
git fetch origin && git rebase origin/main), not merge. - Force-push only with
--force-with-lease. Never plain--force. - Commit (or stash) before you rebase. A dirty tree aborts the rebase.
- One PR per branch. Push additional commits to the same branch; comment on the PR when it is ready for re-review.
- Verify before you push:
git status(right branch, intended files only) andgit log --oneline -5(sane history). - State what changed, not how good it is. No editorializing in commits or PR bodies.
Workflow
1. Orient
git statusandgit branch --show-current: know where you are and what is dirty.- Read the repo's workflow docs first (
CONTRIBUTING.md,AGENTS.md, PR templates). They outrank this skill. - Check for hook configs (
lefthook.yml,.pre-commit-config.yaml,.husky/). If present, they define the commit gate; do not bypass them.
2. Start work
git checkout main
git pull --rebase # or: gh repo sync, for GitHub repos
git checkout -b <type>/<short-kebab-description>
Branch names: feature/, bugfix/, hotfix/, docs/ prefixes with a
kebab-case description (feature/oauth-refresh-token). For open-source
contributions through a fork: clone the upstream repo, add your fork as a
remote, push the branch to the fork, and open the PR against upstream main.
Details: references/branching-strategy.md.
3. Commit
- Stage deliberately:
git add <paths>, notgit add .unless the tree contains only intended changes. - One commit per unit of change.
- Validate the message with
scripts/check-commit-msg(reads a message file or stdin; exit 0 is valid). Install it as.git/hooks/commit-msgto enforce the format.
Format, type table, scopes, and breaking changes: references/conventional-commits.md.
4. Sync while working
git fetch origin
git rebase origin/main
Combine a messy local history before opening the PR: git rebase -i HEAD~n
(squash/fixup) or the soft-reset method (git reset --soft HEAD~n && git commit).
Resolve conflicts, git rebase --continue, then push with
--force-with-lease. Details: references/sync-and-recovery.md.
5. Open the PR
git push -u origin <branch>
gh pr create --title "<type>: <what it does>" --body "<why, what changed, test evidence>"
Title rule: say what the PR does, not which issue it closes; put Fixes #123
in the body. Check status with gh pr status and gh pr view. Feedback loop,
approvals, and merge: references/pr-workflow.md.
6. Merge and clean up
- Merge with the repo's configured method. When the project does not specify one,
gh pr merge --squash --delete-branchis the common default. - After merge:
git checkout main
git pull --rebase
git branch -d <branch>
git remote prune origin
- For stale local branches:
git branch --merged | grep -v '\*\|main\|master' | xargs -n 1 git branch -d.
References
| Reference | Triggers |
|---|---|
references/conventional-commits.md |
commit message format, types, scopes, breaking changes, footers |
references/branching-strategy.md |
branch naming, never-commit-to-main, trunk vs GitHub Flow vs GitFlow vs GitLab Flow vs release vs environment branching, fork-based OSS contributions |
references/pr-workflow.md |
gh PR create/review/merge, the feedback loop, PR titles |
references/sync-and-recovery.md |
rebase, squash, stash, undo levels, reflog, force-with-lease |
references/git-config.md |
sane global git config defaults and aliases (opt-in) |
04 同仓库更多 Skills
shell-script-expert
Use when the user asks "review this script", "write a bash script", "fix my shell script", "make this script safer", "why does this script fail", "convert this to a script", or working with .sh/.bash files, sh/bash syntax, shellcheck, cronjobs, and bash one-liners.
prose-synthesize
Turn unstructured notes into a structured, actionable plan. Use when given brain dumps, stream-of-consciousness, or scattered thoughts needing order.
prose-distill
Condense verbose text to its essence. Use when asked to condense, tighten, shorten, reduce verbosity, or omit needless words while preserving substance.
mindcraft
暂无简介
learn
Tutor for intellectual understanding: teach how or why something works rather than complete a task or provide an evaluative verdict. Trigger for explicit learning requests (teach, explain, ELI5, walkthroughs, quizzes, flashcards, definitions); terse concept prompts; confusion signals; prerequisite or sequencing questions; and conceptual questions about mechanisms, causes, or dynamics. Do not trigger for task completion (coding, writing, calculation, or translation), factual or news lookup, personal troubleshooting, resource recommendations, or opinion and interpretive verdicts.
deployment-readiness
Use to check deployment readiness of a host.