git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature request: git cp

From
Martin Guy <martinwguy@gmail.com>
Date
Nov 20, 2025, 21:24 UTC
Message-ID
<CAL4-wQpeYc8-FfcZGWcs6KmR-oswTs3Kjcc7xAb34cFX7s0c-A@mail.gmail.com>
In-Reply-To
<0e971281-d1c4-4030-9297-f5e2c0765431@app.fastmail.com>

Thanks, but that only seems to affect "git log" retroactively, whereas I'm interested in it being part of the history so that "git blame" knows about it. At present, the blame for a line would end at the time of the split (when the file appears to have been created ex novo) though I suppose people would end up at that break and could then switch to tracking the old file instead.

Maybe I'm expecting too much of git, with all the truly wonderful things it does already, but the idea seems to fit into the current scheme of things as seen from the outside (I don't know how the "git mv" line-based trackback works).

    M

On Thu, 20 Nov 2025 at 16:17, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:

Show 37 quoted lines
>
> On Thu, Nov 20, 2025, at 15:56, Martin Guy wrote:
> > I am splitting a large source file into three smaller ones (mp3.c into
> > mad.c, lame.c and twolame.c)
> > and would like the history to track the relevant lines in each file,
> > like "git mv" does,
> > but I only seem able to do this with one file by "git mv"ing it and
> > copying that to the other
> > as a new file.
> >
> > So what I'd like is "git cp" that is like "git mv" but where blame for
> > both the resulting files
> > goes back the original one, if that's possible and unless there's a
> > way to achieve the same
> > effect that I haven't figured out.
> >
> > A fairly rare thing to wish to do, but may be useful in this case.
>
> Copies and file moves are detected dynamically when you use things like
> `git log`.
>
> Try `git log --stat --find-copies-harder`.  I get this output after copying a file three times.
>
>      README.md => rm1.md | 0
>      README.md => rm2.md | 0
>      README.md => rm3.md | 0
>      3 files changed, 0 insertions(+), 0 deletions(-)
>
> I get this output when I change one of the lines in the same commit on one of the files.
>
>      README.md => rm1.md | 2 +-
>      README.md => rm2.md | 0
>      README.md => rm3.md | 0
>      3 files changed, 1 insertion(+), 1 deletion(-)
>
> This is the first time I’ve tried this option so I don’t know
> more about it.
Previous: D. Ben KnobleNext: D. Ben Knoble
Message 4 of 10 in “Feature request: git cp”
  1. Martin GuyNov 20, 2025
  2. Kristoffer HaugsbakkNov 20, 2025
  3. D. Ben KnobleNov 20, 2025
  4. Martin GuyNov 20, 2025
  5. D. Ben KnobleNov 20, 2025
  6. Lucas Seiki OshiroNov 20, 2025
  7. Martin GuyNov 20, 2025
  8. rsbecker@nexbridge.comNov 21, 2025
  9. Martin GuyNov 21, 2025
  10. Lucas Seiki OshiroNov 21, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.