Git Workflow
Purpose
Provide structured Git workflows for agents working on codebases. Ensure clean history, consistent commit messages, and safe collaboration.
When to Use
- Creating feature branches or bugfix branches
- Writing descriptive commit messages from diffs
- Reviewing staged or unstaged changes before committing
- Resolving merge or rebase conflicts
- Squashing or reorganizing commits
- Rebasing onto main or another branch
- Cherry-picking specific commits
- Setting up branch naming conventions
Workflow
Creating a Branch
git checkout main
git pull --ff-only
git checkout -b <type>/<short-description>
Branch types:
feat/— new featurefix/— bug fixdocs/— documentation changesrefactor/— code refactoringtest/— adding or updating testschore/— maintenance tasksagent/— agent-initiated changes
Writing Commit Messages
Use conventional commits:
<type>(<scope>): <imperative description>
[optional body with context]
[optional footer with breaking changes or refs]
Types: feat, fix, docs, style, refactor, test, chore, perf
Rules:
- Subject line ≤ 72 characters
- Use imperative mood: "add feature" not "added feature"
- Do not end subject with period
- Body explains WHY, not WHAT (diff shows WHAT)
- Reference issues/PRs in footer when applicable
Before Committing
git status— see what changedgit diff— review unstaged changesgit diff --staged— review staged changes- Stage purposefully:
git add -pfor selective staging - Write commit message that explains the intent
Merge Conflict Resolution
- Inspect the conflict markers in each file
- Understand what both sides were trying to do
- Preserve the intent of both changes where possible
- Never blindly choose "ours" or "theirs"
- Test after resolving: run validation, tests, linting
- Stage resolved files:
git add <resolved-files> - Continue:
git rebase --continueorgit commit
Squashing Commits
git rebase -i HEAD~<n>
# Mark commits to squash, keep the first as "pick"
# Write a clean combined commit message
Use squashing when:
- Multiple small commits should be one logical change
- Fixing typos or lint issues immediately after the original commit
- A feature branch has excessive "WIP" commits
Rebasing
git checkout <branch>
git fetch origin
git rebase origin/main
Rebase instead of merge to keep clean history on feature branches.
File References
- Commit Message Templates — templates for common commit types
Source: pbans-agent/skillpack — distributed by TomeVault.