threads / rfc / 63506

[RFC] git-ghost: preserve “why” on deleted lines

Subject: [RFC] git-ghost: preserve “why” on deleted lines

## tl;dr

3 messages between May 23, 2025 and May 23, 2025.

replies: 2people: 3as markdown or json

Max Rhodin· May 23, 2025, 12:32 UTC · lore
Hi,
I hate losing the why behind a deleted line.

When you drop code in a review, being able to attach a brief comment to that line would save a lot of head-scratching.

Git-ghost – see the remnants of days past in a file.

git-ghost hooks into commit to stash deleted lines in a `.ghost` file and enables maintainers to prompt for a short reason. Later you can run:

    git ghost view <file>
to see what vanished and why. Blame also becomes easier.

No core changes—pure userland. Repos can opt in or out. Also helps AI agents make sense of code history.

Could be made in thousands of ways, but unless the deleted rows are saved as actual file-bound information, understanding it later and building tools for it is much harder. `git note` could be used, but doesn't really solve the issue.

Comments?

Max Rhodin max@ux.se

Junio C Hamano· May 23, 2025, 17:24 UTC · re: Max Rhodin · lore

Re: [RFC] git-ghost: preserve “why” on deleted lines

Max Rhodin <max@ux.se> writes:
> Comments?
Would running "git blame" in reverse work for your use case?

Tracing deleted contents is much harder than tracing contents in the current revision, simply because you have to find where to start digging. In order to find where the contents were removed, you first need to know what exact contents you are looking for (which by definition you cannot do with the current revision), and then you need to know what revision had that code.

What I do in practice is to randomly check out an old revision to find sufficiently old one that still contains the contents ("git bisect" can help), and then go from there.

Lucas Seiki Oshiro· May 23, 2025, 19:45 UTC · re: Max Rhodin · lore

Re: [RFC] git-ghost: preserve “why” on deleted lines

> Hi,
Hi, Max!
> I hate losing the why behind a deleted line.
> 
> When you drop code in a review, being able to attach a brief comment
> to that line would save a lot of head-scratching.

Sorry if I misunderstood you, but I can't see the difference of that to committing empty lines + giving a meaningful commit message.

Show 8 quoted lines
> Git-ghost – see the remnants of days past in a file.
> 
> git-ghost hooks into commit to stash deleted lines in a `.ghost` file
> and enables maintainers to prompt for a short reason. Later you can run:
> 
>    git ghost view <file>
> 
> to see what vanished and why. Blame also becomes easier.

I still don't see the difference of that to git log -- <file>. I understand that git blame doesn't show what has been deleted, only what is new and what has changed. But ok, git blame has it's limitations of being a quick line-wise inspection tool, while more deeper analysis would require more powerful tools. It looks to me that git log with some flags would do what you need.

← back to recent threads