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

Re: renaming question

From
AGAaron Gray <angray@beeb.net>
Date
Aug 20, 2007, 01:30 UTC
Message-ID
<045a01c7e2c9$c1ccd940$0600a8c0@ze4427wm>
In-Reply-To
<46C8E421.8000408@midwinter.com>
Show 7 quoted lines
> Florian Weimer wrote:
>> Or, for more control about what gets put into patch, git-diff -M.
>> (As I wrote, most of the relevant commands accept an -M switch.)
>>
>
> The key point, and where the original writer is probably confused, is that 
> in git, renames are inferred from information in the repository.
Okay.
Show 7 quoted lines
> You do not ever need to explicitly tell git about a rename. There is a 
> "git mv" command which is simply a convenience command; it is equivalent 
> to
>
> mv a b
> git add b
> git rm a
That makes things alot clearer, thanks.
Show 11 quoted lines
> When you query history with the -M flag or do merges, git will notice that 
> the contents of the new file "b" are very similar to the old file "a" and 
> will treat it as a rename. (The contents don't have to match exactly; they 
> just have to be substantially similar.)
>
> This is not a perfect system -- there are known cases where it fails -- 
> but it has major advantages too. For example, you can unpack a third-party 
> tarfile into a git repository, commit it, then unpack the next version's 
> tarfile and commit that. Since you are using tar, nothing will have told 
> git about files that the upstream people renamed in between versions, but 
> git will detect them after the fact just as if you'd done "git mv".
Thats great, exactly what I want to do.
Show 5 quoted lines
> Not only that, git can detect movement of content *within* files. Try 
> moving some code from one file to another and running "git blame -M -C -C" 
> on the target file; you will see git tell you that the content originally 
> came from the first file. Pretty sweet. (It's not the default since it 
> makes "git blame" slower.)

Okay. The documentation, or what I have read does not really explain this properly or concisely.

Thanks alot Steve.
Aaron
Previous: Steven GrimmNext: Shawn O. Pearce
Message 9 of 12 in “renaming question”
  1. Aaron GrayAug 19, 2007
  2. Florian WeimerAug 19, 2007
  3. Aaron GrayAug 19, 2007
  4. David KastrupAug 19, 2007
  5. Aaron GrayAug 19, 2007
  6. David KastrupAug 19, 2007
  7. Florian WeimerAug 19, 2007
  8. Steven GrimmAug 20, 2007
  9. Aaron GrayAug 20, 2007
  10. Shawn O. PearceAug 20, 2007
  11. VMiklosAug 20, 2007
  12. Aaron GrayAug 20, 2007

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.