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

Re: possible 'git cp'/how does git detect copies

From
Pierre Habouzit <madcoder@debian.org>
Date
Jun 27, 2008, 13:00 UTC
Message-ID
<20080627130006.GC17898@artemis.madism.org>
In-Reply-To
<4864DFB6.3050204@mircea.bardac.net>
On Fri, Jun 27, 2008 at 12:40:22PM +0000, Mircea Bardac wrote:
> I was looking today at duplicating a file but, I soon realized that there 
> is no 'git cp' command (this was the "deductive approach to git 
> commands", starting from git mv/rm/...). How does "git diff -C" detect 
> copies (-C is used for this, according to the documentation)?
  By comparing if files (blobs) are alike. It has some heuristics to
guess which files have good changes to be copies or renames of each
others. But it recomputes the information each time.
Show 7 quoted lines
> On a very simple test, I couldn't see this working. I just copied one 
> file, added it, committed the change, ran "git diff -C HEAD^!". There is 
> no place saying that it's contents is copied from some other file (both 
> files are in the repository now).
> 
> "git blame -C new_copied_file" also doesn't show the commits for the 
> original file.
  You probably want to use -C -C -M actually.
> I found this older thread [1] on "git cp" but the discussion appears to 
> have stalled at some point. If there is indeed no use of a "git cp" 
> command, I would like at least some info on how content copies are being 
> detected, since I haven't seen this working.
  If you really need it, you can and an alias alias.cp=!cp and be done
with it ;P
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Mircea BardacNext: Miklos Vajna
Message 4 of 6 in “possible 'git cp'/how does git detect copies”
  1. Mircea BardacJun 27, 2008
  2. Santi BéjarJun 27, 2008
  3. Mircea BardacJun 27, 2008
  4. Pierre HabouzitJun 27, 2008
  5. Miklos VajnaJun 27, 2008
  6. Johannes SixtJun 27, 2008

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.