agentsclimarketplace

Git workflow

Skill JayRHa/AgentSkills/git-workflow

The largest community-driven library of Agent Skills (SKILL.md + scripts/references/examples) for Claude, Codex, Gemini CLI, Cursor and friends.

Install
npx -y skills add JayRHa/AgentSkills --skill git-workflow

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Guides safe, professional Git usage — branching strategies, atomic clean commits, conventional commit messages, interactive rebase (squash/fixup/reword/reorder), merge vs rebase decisions, conflict resolution, and recovery of lost work via reflog. Use this skill when the user asks to create or clean up a branch, write or amend commits, squash or reorder history, rebase onto main, resolve merge conflicts, undo a bad commit/merge/reset, recover deleted commits or branches, find lost work, fix a detached HEAD, force-push safely, or generally "clean up my git history" before opening a PR.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.5 KB, ~1.9k tokens by cl100k_base, as published. Nobody here has run it

Git Workflow

Overview

This skill provides a disciplined, safe workflow for everyday Git: branching, crafting clean atomic commits, rewriting history with interactive rebase, resolving conflicts, and recovering from mistakes using the reflog. The guiding principle is safety first — never destroy work you cannot recover, always know your escape hatch before running a history-rewriting command.

Keywords: git, branch, commit, rebase, interactive rebase, squash, fixup, reword, cherry-pick, merge, conflict, conflict resolution, reflog, recover lost commits, undo, reset, revert, detached HEAD, force-push, stash, clean history, conventional commits, PR prep.

Golden rules

  1. Never rewrite history that others have already pulled (shared branches like main/develop). Rewrite only your own unmerged feature branches.
  2. Before any rebase, reset --hard, or force-push, note the current commit: git rev-parse HEAD or just trust the reflog — it remembers.
  3. Prefer git push --force-with-lease over --force. It refuses to clobber commits you haven't seen.
  4. Commit early, commit often locally; clean up into atomic commits before sharing.
  5. If something looks lost, it almost certainly isn't — go to git reflog (see references/reflog-recovery.md).

Workflow

1. Orient before acting

Always understand current state first:

git status            # working tree + branch
git log --oneline -10 # recent history
git branch -vv        # branches + tracking

2. Branch

  • Update the base first: git switch main && git pull --ff-only.
  • Create the branch: git switch -c feat/short-description.
  • Naming: <type>/<slug> e.g. feat/oauth-login, fix/null-deref, chore/bump-deps, docs/readme. See references/branch-naming.md.

3. Make atomic commits

  • One logical change per commit. Stage selectively: git add -p to split a working tree into focused hunks.
  • Write a Conventional Commit message (see references/conventional-commits.md):
    feat(auth): add OAuth2 PKCE login flow
    
    Body explaining WHY, wrapped at ~72 cols. Reference issues.
    
  • Verify before committing: re-read git diff --staged.

4. Keep up to date with the base

Choose merge vs rebase intentionally (see decision framework below). For a private feature branch, rebasing keeps history linear:

git fetch origin
git rebase origin/main

5. Clean up history before opening a PR

Squash noise ("wip", "fix typo"), reword unclear messages, reorder for logical flow:

git rebase -i origin/main

Full guidance and the command cheat sheet: references/interactive-rebase.md. Validate the result before pushing: scripts/rebase-safety-check.sh.

6. Resolve conflicts methodically

When a rebase/merge stops on a conflict, follow the step-by-step protocol in references/conflict-resolution.md. Summary:

git status                 # see conflicted files
# edit files, remove <<<<<<< ======= >>>>>>> markers
git add <resolved-files>
git rebase --continue      # or: git merge --continue
# abort anytime: git rebase --abort / git merge --abort

7. Share

git push -u origin feat/short-description           # first push
git push --force-with-lease                         # after a rebase/amend

8. Recover when things go wrong

Nothing is lost until garbage collection runs (default ~30–90 days). See references/reflog-recovery.md and run scripts/git-recover.sh to surface candidate lost commits.

Decision Framework: Merge vs Rebase

SituationUse
Updating your private, unpushed feature branch with latest maingit rebase origin/main (linear history)
Branch is shared / others have it checked outgit merge origin/main (don't rewrite shared history)
Combining a finished feature into main (team prefers linear)rebase then fast-forward / squash-merge
Combining a feature, preserving full context & merge pointgit merge --no-ff
You just want to grab one commit from another branchgit cherry-pick <sha>

Rule of thumb: rebase local, merge shared.

Interactive Rebase Quick Reference

In the git rebase -i todo list, set the action keyword on each line:

KeywordEffect
pickkeep the commit as-is
reword (r)keep changes, edit the message
edit (e)stop to amend the commit (split, add files)
squash (s)merge into previous commit, combine messages
fixup (f)merge into previous commit, discard this message
drop (d)remove the commit entirely
reordermove lines up/down to reorder commits

Targeted fixup workflow (best for PR review fixes):

git commit --fixup=<sha>          # creates "fixup! ..." commit
git rebase -i --autosquash origin/main   # auto-positions & marks it fixup

Recovery Cheat Sheet

ProblemFix
Bad last commit, want to redo messagegit commit --amend
Undo last commit, keep changes stagedgit reset --soft HEAD~1
Undo last commit, keep changes unstagedgit reset HEAD~1
Discard last commit AND its changesgit reset --hard HEAD~1 (recoverable via reflog)
Revert a commit already pushed/sharedgit revert <sha> (new commit, safe)
Lost commits after bad reset/rebasegit reflog then git reset --hard <sha>
Deleted a branch by accidentgit reflog → find tip sha → git branch <name> <sha>
Detached HEAD with work to keepgit switch -c rescue-branch immediately
Accidentally committed to mainbranch it off, then reset main: see references/reflog-recovery.md
Drop unstaged local changesgit restore <file> / git restore .
Stash WIP to switch contextgit stash push -m "msg"git stash pop

Best Practices

  • Make the first line of a commit ≤ 50 chars, imperative mood ("add", not "added").
  • Run scripts/rebase-safety-check.sh after a rebase to confirm no commits were silently dropped and the tree still matches expectations.
  • Use git add -p to keep commits atomic instead of git add ..
  • Prefer git switch/git restore over the overloaded git checkout.
  • Tag the pre-rebase state if nervous: git tag backup-before-rebase. Delete it when done.
  • Configure git config rerere.enabled true to let Git remember conflict resolutions across repeated rebases.

Common Pitfalls

  • Force-pushing a shared branch and erasing teammates' commits. Use --force-with-lease, and never on main.
  • Rebasing main/develop — rewriting public history breaks everyone. Use revert instead.
  • git reset --hard without checking — you lose uncommitted working-tree changes permanently (these are NOT in the reflog). Stash first.
  • Resolving a conflict by deleting the wrong side — read both sides; the markers are <<<<<<< HEAD (current/your side during merge) vs >>>>>>> branch (incoming). During rebase the sides are swapped — see references/conflict-resolution.md.
  • Committing generated files / secrets — review git diff --staged; use .gitignore.
  • Assuming work is gone after a botched rebase — check git reflog before doing anything else.

Bundled Files

  • references/interactive-rebase.md — complete interactive rebase guide with worked scenarios.
  • references/conflict-resolution.md — step-by-step conflict protocol, marker semantics, rerere, tools.
  • references/reflog-recovery.md — recover lost commits, branches, resets, detached HEAD, wrong-branch commits.
  • references/conventional-commits.md — message format, types, scopes, breaking changes, examples.
  • references/branch-naming.md — naming conventions and branching models.
  • scripts/git-recover.sh — list recently dangling/unreachable commits with previews to aid recovery.
  • scripts/rebase-safety-check.sh — sanity-check history after a rebase against the upstream base.
  • examples/squash-feature-branch.md — end-to-end worked example of cleaning a messy branch.

Gives 2 of the 12 instructions most pr commit review skills give in ~1.9k tokens

Counted across 888 of the 1,342 authors here whose files we hold, read 2026-08-06

  • use conventional commits formathere, and in 123 of 888, across 110 files
  • keep subject line under 72 charactersin 60 of 888, across 46 files
  • delete branches after mergein 50 of 888, across 37 files
  • use imperative mood in subject linein 50 of 888, across 41 files
  • use imperative mood in commit messagesin 45 of 888
  • generate a conventional commit messagein 42 of 888
  • make atomic commitshere, and in 37 of 888, across 25 files
  • run tests before committingin 36 of 888, across 24 files
  • run project test suite to verify clean baselinein 35 of 888, across 7 files
  • run detected project setup commandsin 34 of 888, across 6 files
  • wrap commit body at 72 charactersin 32 of 888, across 25 files
  • split unrelated changes into separate commitsin 32 of 888, across 27 files

Said here and by no other author read

  • note current HEAD before rewriting history
  • update base branch before branching
  • run rebase safety checks after rebasing
  • prefer switch over checkout

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.