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

Re: git rename/moved status unreliable in ruby

From
Junio C Hamano <gitster@pobox.com>
Date
May 3, 2026, 21:59 UTC
Message-ID
<xmqqo6iwrw6k.fsf@gitster.g>
In-Reply-To
<026b84f4-7052-4d5b-a9ae-c2487569d1ee@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 17 quoted lines
> Hi Sebastien
>
> On 01/05/2026 06:05, sebastien.stettler wrote:
>> 1. What did you do before the bug happened? (Steps to reproduce your issue)
>> 
>> when moving ruby classes between namespaces they are marked as new files and the old
>> ones are marked as deleted
>> 
>> if i only change the class name it will mark it as renamed
>
> Rename detection is based on how similar the two files are. Looking at 
> the example you linked to below you're changing a file that looks like
> ...
> Which means that git sees that every line has changed because the 
> indentation has changed. If you want git to realize that the file has 
> been renamed you could move it in one commit and then add modify it in 
> the next commit.

I've seen this repeated many times, but it is misleading to give it without qualifying when that "works" and when it does not. Such a "stick to pure rename and make huge changes elsewhere" strategy would help your "git log -M [--follow]" and possibly "git rebase", but it would not help all that much if you are doing "git diff" or "git merge".

    
Previous: Johannes SixtNext: Chris Torek
Message 4 of 9 in “git rename/moved status unreliable in ruby”
  1. sebastien.stettlerMay 1, 2026
  2. Phillip WoodMay 1, 2026
  3. Johannes SixtMay 2, 2026
  4. Junio C HamanoMay 3, 2026
  5. Chris TorekMay 2, 2026
  6. sebastien.stettlerMay 2, 2026
  7. Jeff KingMay 4, 2026
  8. Junio C HamanoMay 5, 2026
  9. Chris TorekMay 5, 2026

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.