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

3 messages from 2025-05-23 to 2025-05-23. Participants: Max Rhodin, Junio C Hamano, Lucas Seiki Oshiro.
Thread: https://gitlist.dev/t/63506

## Max Rhodin, 2025-05-23 12:32

Subject: [RFC] git-ghost: preserve “why” on deleted lines
Message-ID: <CAOc+UT0n9pRGur0d4cORU0SMQY-PNs5ekLd=LX9xc940Og+nrQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAOc%2BUT0n9pRGur0d4cORU0SMQY-PNs5ekLd%3DLX9xc940Og%2BnrQ%40mail.gmail.com

```
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, 2025-05-23 17:24

Subject: Re: [RFC] git-ghost: preserve “why” on deleted lines
Message-ID: <xmqqh61bxmsj.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqh61bxmsj.fsf%40gitster.g
In-Reply-To: <CAOc+UT0n9pRGur0d4cORU0SMQY-PNs5ekLd=LX9xc940Og+nrQ@mail.gmail.com>

```
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, 2025-05-23 19:45

Subject: Re: [RFC] git-ghost: preserve “why” on deleted lines
Message-ID: <9F0F0FF5-85D8-48E8-B056-F71F56AEB915@gmail.com>
URL: https://gitlist.dev/e/9F0F0FF5-85D8-48E8-B056-F71F56AEB915%40gmail.com
In-Reply-To: <CAOc+UT0n9pRGur0d4cORU0SMQY-PNs5ekLd=LX9xc940Og+nrQ@mail.gmail.com>

```

> 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.

> 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.


```
