cd /news/ai-tools/the-git-commands-you-forgot-exist-an… Β· home β€Ί topics β€Ί ai-tools β€Ί article
[ARTICLE Β· art-13836] src=dev.to pub= topic=ai-tools verified=true sentiment=Β· neutral

The git Commands You Forgot Exist (And Why AI Workflows Make Them Relevant Again)

A developer has highlighted several lesser-known Git commands that are gaining renewed relevance in AI-assisted coding workflows. Commands like `git worktree` allow multiple independent working directories from a single repository, enabling AI coding agents to operate on different branches simultaneously without context loss. Other commands such as `git bisect run`, `git rerere`, and `git log -S` offer powerful capabilities for automated regression testing, conflict resolution, and content-based search that streamline development processes.

read4 min publishedMay 25, 2026

Most devs know git commit, git push, git stash. Then there's a whole floor below that nobody visits.

Try it yourself:clone[git-archaeology-lab], runbash setup.sh

, and every command in this article has a working exercise waiting for you.

git worktree

β€” multiple checkouts, one repo This one is criminally underused. By default, git lets you have exactly one working directory per clone. git worktree

breaks that constraint.

You now have two fully independent working directories β€” same repo, different branches β€” with no stashing, no switching, no context loss.

Why it's back: AI coding agents. When you're running Claude Code or Cursor on one branch and need to review a hotfix on another, switching branches mid-session breaks everything. git worktree

lets both live simultaneously. Each agent gets its own tree. No collisions.

git bisect

β€” binary search your blame You have a bug. You know it didn't exist three weeks ago. You have 200 commits in between. git bisect

turns that into about 8 tries.

The real power is git bisect run

β€” pass any command that exits 0 (good) or non-zero (bad). Your whole test suite, a curl health check, a grep β€” anything that detects the regression works as the oracle. git drives itself to the culpable commit with zero manual steps.

git rerere

β€” never resolve the same conflict twice rerere

= Re use Re corded Re solution.

Enable it once globally and forget it's there β€” until you notice conflicts silently resolving themselves. The payoff is most obvious during long interactive rebases where the same conflict appears across a dozen commits.

git log -S

β€” the pickaxe You want to know when a specific string was added or removed. Not which commit touched the file β€” which commit changed this exact text.

-S

searches diff content, not commit messages. It finds commits where the string's count in a file changed β€” added or removed. Even after a secret is deleted from HEAD, git log -S

finds the commit that introduced it. Deletion isn't enough. Rotate the credential.

git notes

β€” annotate commits without touching them Commits are immutable. But sometimes you want to attach information to one β€” a JIRA ticket, a test result, a deployment timestamp β€” after the fact, without rewriting history.

Notes live in a separate ref (refs/notes/commits

) and don't alter the commit hash. Great for CI/CD pipelines that want to annotate commits with build metadata without touching history.

git range-diff

β€” diff of diffs You rebased a branch. You want to verify the rebase didn't silently mangle any patches. git range-diff

compares two sequences of commits patch-by-patch.

=

means the patches are equivalent. !

means something drifted β€” and git shows you the diff-of-diffs inline. Code review tools don't show you this. Only range-diff

does.

git sparse-checkout

β€” check out only what you need Mono-repo with 40 packages and you only work in two? Sparse checkout lets you tell git to only materialize specific paths.

Everything else exists in git history but won't appear on disk. Your editor is faster. Your find

commands are sane. In an AI workflow, sparse checkout reduces the surface area your agent sees β€” fewer files means faster greps, leaner context windows, and no accidental edits to packages you don't own.

git commit --fixup

  • git rebase --autosquash

You committed, reviewed your own diff, spotted a typo in the third commit back. There's a clean path that doesn't require a painful interactive rebase.

--fixup

is the honest alternative to git commit --amend

. Amend rewrites HEAD; fixup targets any prior commit and leaves an auditable trail until the rebase squashes it.

git blame -C

β€” follow moved code Standard git blame

breaks when code moves between files. -C

tells git to detect copied or moved content and attribute it correctly.

Any time you move functions between files, copy-detection blame gives you the true lineage β€” who decided this logic should work this way, not just who moved it.

git bundle

β€” the git sneakernet No network. Air-gapped machine. USB drive. git bundle

packs your entire repo (or a range of commits) into a single file you can carry anywhere.

The bundle is a valid git remote. You can clone from it, fetch from it, inspect it. It's just a file.

Knowing the commands is one thing. Knowing which one to reach for in the moment is another.

The lab repo ships a Claude Code skill file at .claude/skills/git-archaeology.md

. When you open the repo in Claude Code, the skill is available automatically. Describe your problem in plain English β€” "I need to find when this bug appeared", "I keep resolving the same conflict", "can I have two branches open at once?" β€” and it reasons through the right command for your specific situation.

To install it in any of your own projects:

mkdir -p .claude/skills
curl -sL https://gist.githubusercontent.com/copyleftdev/c9c12ea89231680d5ef4a68785ecc125/raw/git-archaeology.md \
  > .claude/skills/git-archaeology.md

These aren't obscure for obscurity's sake. They were built for problems that are more common now than they were in 2012 β€” big repos, parallel workstreams, automated agents, compliance trails. The commands existed. The problems caught up.

Want to run every command in this article against real git history?

β†’ git-archaeology-lab β€” clone it, run bash setup.sh

, open exercises/

.

Which one did you not know about? Drop it in the comments.

Tags: git productivity devtools ai linux

── more in #ai-tools 4 stories Β· sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/the-git-commands-you…] indexed:0 read:4min 2026-05-25 Β· β€”