agentleFS
CloudAI-XCloudAI-X/opencode-workflow/skills/managing-git/SKILL.md

managing-git

Skill275 starsChanged 10 months agoMITView on GitHub

Guides git workflows, branching strategies, commit conventions, and version control best practices. Use when managing repositories, creating branches, or handling merges.

  • Deletes or force-pushes
  • Commits and pushes

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. CloudAI-X/claude-workflow★ 1.4ksame name
    2. CloudAI-X/claude-workflow-v2★ 1.4ksame name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep short but descriptive

    line 162

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Managing Git

Best practices for version control, branching strategies, and collaborative development.

When to Use This Skill

  • Setting up branching strategies
  • Writing commit messages
  • Handling merges and conflicts
  • Managing releases
  • Code review workflows
  • Maintaining clean history

Branching Strategies

Git Flow

main ─────●─────────────────────●─────────────────●────▶
           \                   /                 /
release     \───────●─────────●                 /
              \                                /
develop ───────●───────●───────●──────●───────●────────▶
                \       \       \      \
feature          \───────●───────●      \───●───●
                          \              \
hotfix                     \              \───●────▶ main
BranchPurposeBranches FromMerges Into
mainProduction code--
developIntegrationmainrelease
feature/*New featuresdevelopdevelop
release/*Release prepdevelopmain, develop
hotfix/*Production fixesmainmain, develop

Use when: Scheduled releases, multiple versions supported

GitHub Flow

main ─────●─────●─────●─────●─────●────▶
           \   /       \   /       \   /
feature     ●─●         ●─●         ●─●
            PR          PR          PR
BranchPurpose
mainAlways deployable
feature/*All changes (features, fixes)

Use when: Continuous deployment, simple workflow

Trunk-Based Development

main ─────●──●──●──●──●──●──●──●──●──●────▶
           │  │  │  │  │  │  │  │  │  │
          ●   ●  ●  ●  ●  ●  ●  ●  ●  ●
          Small, frequent commits (often direct to main)

Use when: High trust teams, strong CI/CD, frequent deploys


Commit Message Conventions

Conventional Commits

<type>(<scope>): <subject>

<body>

<footer>

Types

TypeDescriptionExample
featNew featurefeat(auth): add OAuth2 login
fixBug fixfix(api): handle null response
docsDocumentationdocs(readme): update setup steps
styleFormattingstyle: fix indentation
refactorCode restructuringrefactor(db): simplify query builder
testAdding teststest(user): add registration tests
choreMaintenancechore(deps): update lodash
perfPerformanceperf(search): add index on email
ciCI/CD changesci: add Node 18 to matrix

Good vs Bad Commits

BAD:
  - "fix"
  - "update code"
  - "WIP"
  - "changes"
  - "asdfasdf"

GOOD:
  - "fix(auth): prevent session timeout on idle"
  - "feat(cart): add quantity validation"
  - "refactor(api): extract common error handling"

Commit Body Guidelines

fix(payment): prevent double charge on retry

The payment gateway timeout was causing the retry logic to submit
duplicate charges. Added idempotency key to prevent double-processing.

Closes #1234
  • First line: 50 chars max, imperative mood
  • Body: Wrap at 72 chars, explain why, not what
  • Footer: Reference issues, breaking changes

Branch Naming Conventions

Pattern

<type>/<ticket>-<short-description>

Examples

TypeExample
Featurefeature/AUTH-123-add-oauth-login
Bugfixfix/CART-456-quantity-validation
Hotfixhotfix/PROD-789-memory-leak
Chorechore/update-dependencies
Docsdocs/api-documentation

Branch Rules

  1. Lowercase with hyphens
  2. Include ticket number when available
  3. Keep short but descriptive
  4. Delete after merge

Git Workflow Commands

Daily Workflow

# Start new feature
git checkout main
git pull origin main
git checkout -b feature/AUTH-123-add-login

# Work on feature
git add -p                    # Stage hunks interactively
git commit -m "feat(auth): add login form"

# Keep up to date
git fetch origin
git rebase origin/main        # Preferred: clean history
# OR
git merge origin/main         # Alternative: preserves context

# Push and create PR
git push -u origin feature/AUTH-123-add-login

Useful Commands

CommandPurpose
git stashSave uncommitted changes temporarily
git stash popRestore stashed changes
git commit --amendModify last commit
git rebase -i HEAD~3Interactive rebase (squash, reorder)
git cherry-pick <sha>Apply specific commit
git bisectBinary search for bug introduction
git reflogView all HEAD movements (recovery)

Cleanup Commands

# Delete merged branches locally
git branch --merged | grep -v main | xargs git branch -d

# Prune remote tracking branches
git fetch --prune

# Clean untracked files (careful!)
git clean -fd

Handling Conflicts

Conflict Resolution Flow

1. Identify conflicts
   git status

2. Open conflicted files
   <<<<<<< HEAD
   your changes
   =======
   their changes
   >>>>>>> feature-branch

3. Resolve (keep one, combine, or rewrite)

4. Mark resolved
   git add <resolved-file>

5. Continue
   git rebase --continue   # if rebasing
   git commit              # if merging

Prevention Strategies

  1. Small, frequent merges - Reduce conflict scope
  2. Communication - Coordinate on shared files
  3. Feature flags - Reduce long-lived branches
  4. Clear ownership - Minimize overlapping work

Pull Request Best Practices

PR Checklist

  • Branch is up to date with main
  • Tests pass locally
  • Linting passes
  • Self-review completed
  • Documentation updated
  • Ticket/issue linked
  • Screenshots for UI changes

PR Size Guidelines

SizeLines ChangedReview TimeRecommendation
Small1-10015 minIdeal
Medium100-40030-60 minAcceptable
Large400+1+ hourSplit if possible

PR Description Template

## Summary
Brief description of changes

## Changes
- Added X
- Modified Y
- Removed Z

## Testing
- [ ] Unit tests added
- [ ] Manual testing done

## Screenshots (if applicable)
[Before/After images]

## Related Issues
Closes #123

Release Management

Semantic Versioning

MAJOR.MINOR.PATCH
  │     │     │
  │     │     └── Bug fixes (backward compatible)
  │     └── New features (backward compatible)
  └── Breaking changes

Release Process

# Create release branch
git checkout -b release/v1.2.0 develop

# Bump version, update changelog
# ... make changes ...

# Merge to main and tag
git checkout main
git merge release/v1.2.0
git tag -a v1.2.0 -m "Release v1.2.0"
git push origin main --tags

# Merge back to develop
git checkout develop
git merge release/v1.2.0

Changelog Format

# Changelog

## [1.2.0] - 2024-01-15
### Added
- OAuth2 authentication support

### Changed
- Improved error messages

### Fixed
- Memory leak in cache handler

### Deprecated
- Old authentication method (use OAuth2)

### Removed
- Legacy API v1 endpoints

Git Hooks

Common Hooks

HookTimingUse Case
pre-commitBefore commitLinting, formatting
commit-msgAfter messageValidate message format
pre-pushBefore pushRun tests
post-mergeAfter mergeInstall dependencies

Example pre-commit

#!/bin/sh
# .git/hooks/pre-commit

# Run linter
npm run lint
if [ $? -ne 0 ]; then
  echo "Linting failed. Please fix errors."
  exit 1
fi

# Run tests
npm test
if [ $? -ne 0 ]; then
  echo "Tests failed. Please fix before committing."
  exit 1
fi

Using Husky (Node.js)

// package.json
{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  }
}

Troubleshooting

Common Issues

ProblemSolution
Accidental commit to maingit reset HEAD~1 (before push)
Wrong branchgit stash, switch, git stash pop
Need to undo mergegit revert -m 1 <merge-commit>
Lost commitsgit reflog to find, git cherry-pick
Large file committedgit filter-branch or BFG Repo-Cleaner

Recovery Commands

# Undo last commit (keep changes)
git reset --soft HEAD~1

# Undo last commit (discard changes)
git reset --hard HEAD~1

# Recover deleted branch
git reflog
git checkout -b recovered-branch <sha>

# Undo a pushed commit (safe)
git revert <sha>

Anti-Patterns to Avoid

  1. Force pushing to shared branches - Breaks others' history
  2. Giant commits - Hard to review, hard to bisect
  3. Vague commit messages - "fix" tells nothing
  4. Long-lived branches - Merge conflict hell
  5. Committing generated files - Bloats repo, causes conflicts
  6. Committing secrets - Security risk (even after removal)
  7. Rebasing public history - Breaks collaborators
  8. Ignoring CI failures - Broken windows effect

Quick Reference

BRANCHES:
  main       → Production (protected)
  develop    → Integration (Git Flow)
  feature/*  → New work
  fix/*      → Bug fixes
  hotfix/*   → Production emergencies

COMMITS:
  feat(scope): add feature
  fix(scope): fix bug
  docs(scope): update docs
  refactor(scope): restructure code

DAILY FLOW:
  git checkout -b feature/ticket-desc
  git add -p && git commit
  git rebase origin/main
  git push -u origin feature/ticket-desc

VERSIONING:
  MAJOR.MINOR.PATCH
  Breaking.Feature.Bugfix

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.