agentsclimarketplace

Git revisions syntax

Skill narenaryan/agent-skills/skills/git/git-revisions-syntax

Byte-sized agent skills for giving advanced knowledge to AI agents

Install
npx -y skills add narenaryan/agent-skills --skill git-revisions-syntax

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

  • 0 stars0 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

Use when selecting commits, ranges, or historical refs in git — covers ^, ~, .., ..., @{N}, @{time}, --not, and pickaxe content selectors

SKILL.md

2.0 KB, as published. Nobody here has run it

Git Revision Syntax

Single Commits

SyntaxMeaning
abc123SHA prefix (≥4, unambiguous)
HEAD / @current commit
HEAD^first parent
HEAD^2second parent (merge's other side)
HEAD~Nwalk N steps along first parent
HEAD~3^2chained: grandparent's merge sibling
HEAD@{2}2 reflog entries ago
HEAD@{yesterday} / @{2.weeks.ago}reflog by time
@{-1}previously checked-out branch
@{u} / @{push}upstream / push target
tag^{}deref annotated tag to commit
:/fix typonewest commit whose msg matches regex

^N picks parent N of one commit (merge-aware). ~N walks N first-parent steps. Different.

Ranges

SyntaxMeaning
A..Bin B, not A
A...Bsymmetric diff (either but not both)
^A B / B --not Asame as A..B
A B ^Cin A or B, not C
git log origin/main..HEAD              # unpushed
git log --left-right main...feature    # side-marked
git log HEAD --not release/*

Content-Based Selectors

git log -S"token"                  # commits where literal token count changed
git log -S"pat" --pickaxe-regex
git log -G"regex"                  # commits touching any matching line
git log -L :funcName:file.js       # evolution of a function
git log -L 10,20:file.js           # evolution of line range

-S = added/removed detection; -G = any line touching pattern.

Plumbing

git rev-parse HEAD~3               # resolve to full SHA
git merge-base A B                 # nearest common ancestor
git name-rev <sha>                 # which branch/tag contains it

Pitfalls

  • Reflog selectors (@{N}, @{time}) are local, expire (~90 days).
  • HEAD^ in zsh/PowerShell needs quoting.
  • A..B is empty if B is an ancestor of A — probably want B..A.

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.