PricingSign inDownload

Blog / git

See a file's history after a coding agent renamed it

git log shows one commit for a file your agent moved. Follow it across the rename, make blame see past it, and get renames git missed.

On this page
  1. git log stops at the rename
  2. Blame already crosses simple renames
  3. When the agent renamed and rewrote in one commit
  4. Lower the threshold
  5. Make blame look harder
  6. Find a renamed file you've lost track of
  7. Stop it happening again
  8. Where Joxo fits
  9. Frequently asked questions
  10. Why does git log show only one commit for my file?
  11. Does git blame follow renames?
  12. Why doesn't git detect my rename?
  13. Can git log --follow work on a folder?
  14. What does R095 mean in git log?
  15. How do I keep history when a coding agent renames files?
  16. Try it with your team

Your agent tidied the project: src/utils.js became src/lib/helpers.js, maybe converted to TypeScript on the way. Now git log on the file shows a single commit, "Agent: move utils into lib", and git blame says the agent wrote every line. The history is still there. Git just needs to be told to look across the rename. We ran every command with git 2.43 on a test repository.

git log stops at the rename#

By default, git log -- <path> only looks at that exact path:

bash
git log --oneline -- src/lib/helpers.js
52282fd Agent: move utils into lib

Add --follow and git tracks the file back through its old name:

bash
git log --oneline --follow -- src/lib/helpers.js
52282fd Agent: move utils into lib
ae8864c Fix v3
e4caad7 Add utils

To see which name the file had in each commit, add --name-status:

bash
git log --follow --name-status --format='%h %s' -- src/lib/helpers.js
52282fd Agent: move utils into lib

R095	src/utils.js	src/lib/helpers.js
ae8864c Fix v3

M	src/utils.js
e4caad7 Add utils

A	src/utils.js

R095 means git matched the old and new file as a rename, 95% the same. --follow works on one file at a time; for a folder, run git log on the old path as well, since the old commits are still recorded under it.

Blame already crosses simple renames#

git blame follows renames on its own when the content is mostly unchanged. Each line shows the path it had in the commit that last changed it:

bash
git blame -s src/lib/helpers.js
ae8864c6 src/utils.js        3) export const v3 = 33;
52282fde src/lib/helpers.js  5) export const v5 = 55;
^e4caad7 src/utils.js        7) export const v7 = 7;

Line 5 really was changed in the move commit. The others go back to who wrote them. If you see this, git found the rename and you're done.

When the agent renamed and rewrote in one commit#

Agents often move a file and change it in the same commit: a new name, a new extension, types added, imports rewritten. Git decides a file was renamed by comparing contents, and by default it needs them to be at least 50% the same. Change more than that and git sees a deleted file and a brand new one:

bash
git show --stat --format=%s HEAD
Agent: convert utils to TypeScript

 helpers.ts | 10 ++++++++++
 utils.js   | 10 ----------
 2 files changed, 10 insertions(+), 10 deletions(-)

Now --follow stops at the move, because to git there's nothing to follow:

bash
git log --oneline --follow -- helpers.ts
a457286 Agent: convert utils to TypeScript

Lower the threshold#

Tell git to accept a weaker match with -M and a percentage:

bash
git log --oneline --follow -M30% -- helpers.ts
a457286 Agent: convert utils to TypeScript
71a8b0f Add utils

The same option works on git show, git diff and git log --stat:

bash
git diff -M30% --name-status HEAD~1 HEAD
R030	utils.js	helpers.ts

Too low a number can pair up files that only look alike, such as two small config files. Start around 30% and check that the pair makes sense.

Make blame look harder#

Blame has no percentage option, but -C tells it to look for lines that came from other files changed in the same commit:

bash
git blame -s -C helpers.ts
a457286e helpers.ts  1) export const v1: number = 1 * 2;
^71a8b0f utils.js    7) export const v7 = 7;
^71a8b0f utils.js    8) export const v8 = 8;

Without -C, line 8 was blamed on the agent's commit. With it, the line goes back to its real author. -C -C also searches the commit that created the file, and -C -C -C searches every commit, which is slow on big projects but finds lines copied from anywhere.

Find a renamed file you've lost track of#

If you only remember the old name, ask git when that path disappeared:

bash
git log --oneline --diff-filter=D -- src/utils.js

That prints the commit where the path was deleted or renamed away. Show that commit with --stat to see where the file went. For tracing a single line across all of this, see find when a coding agent changed a line.

Stop it happening again#

The fix that makes every tool happy is to keep the rename on its own:

  • Rename in one commit, edit in the next. A commit that only moves files is a 100% match, so --follow, blame and every code review tool track it. Then the rewrite is a normal edit on the new path. We split the same change into two commits and git log --follow found all three, with no -M needed.
  • Use git mv. It isn't required, since git works out renames from content, but it stages the delete and the add together so the agent can't forget half.
  • Say so in the instructions file. Add to CLAUDE.md or AGENTS.md: "When moving or renaming files, commit the move by itself before changing their contents."
  • Split an existing commit. If the agent already did both in one commit and it isn't pushed, split the commit into the move and the edit.

Where Joxo fits#

Big moves are where two agents on one project collide: one renames a folder while the other is still editing the old path. In Joxo, agents on a project see what each other is working on and can hand work over before a rename lands on top of someone's changes. Setup is one line pasted into your agent.

Frequently asked questions#

Why does git log show only one commit for my file?#

The file was renamed, and git log -- <path> only looks at the current path. Add --follow to see the commits from before the rename.

Does git blame follow renames?#

Yes, when the file is mostly unchanged by the move. If the rename came with big edits, run git blame -C to find lines that came from the old file.

Why doesn't git detect my rename?#

Git treats a file as renamed when old and new contents are at least 50% the same. If the agent changed more than that in the same commit, use -M30% or a similar value with git log, git show or git diff.

Can git log --follow work on a folder?#

No, --follow takes a single file. For a folder, run git log on both the old and new paths.

What does R095 mean in git log?#

The file was renamed, and the old and new versions are 95% the same.

How do I keep history when a coding agent renames files?#

Have the agent commit the rename on its own, then make its edits in a separate commit.