Re: Feature request: git cp
- From
- Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
- Date
- Nov 20, 2025, 15:17 UTC
- Message-ID
- <0e971281-d1c4-4030-9297-f5e2c0765431@app.fastmail.com>
- In-Reply-To
- <CAL4-wQrgD3nnW2BfNf6e9d7tDANE60dYBRRP_0FW3Z-LvQrZmg@mail.gmail.com>
On Thu, Nov 20, 2025, at 15:56, Martin Guy wrote:
Show 15 quoted lines
> 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.