agentleFS
narenaryannarenaryan/agent-skills/skills/git/git-revisions-syntax/SKILL.md

git-revisions-syntax

Skill0 starsChanged 39 days agoMITView on GitHub

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

The file

Files
SKILL.md

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.

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.