Hacer que git ignore el cambio de nombre [duplicado]

Tengo un archivo foo.txt which I want to delete, and another, bar.txt, that I wish to add. If these two files have more than 50% content that is the same, Git will consider that foo.txt está siendo renombrado a bar.txt. How can I make Git really see this as an individual remove, with an individual add, in the same commit, without changing the global threshold detection %.


preguntado el 09 de marzo de 12 a las 22:03

Is there a particular reason that it being logged as a "rename" is a problem? -

The problem is that the two files should not have their history mingled. Suppose I have a file titled JohnDoe.txt that contains John's work address and phone number of 555-555-1212. John leaves the company at the same time as Jane Smith joins the company (creating file JaneSmith.txt). Her work address is the same, but the phone number is 555-555-1313. If the two add/rm are part of the same commit, Git will consider it a rename and git log --follow will tell me they were the same file (when I patently don't want them to be). Suggestions? -

@poke I'm not clear on how duplicate works. My question was asked a year before the one you've identified. Do you go by "most complete" answer? -

@torngat The other question was previously closed pointing to this question, but I believe that the other question covers the resoning behind Git’s behavior a bit better so I inverted the direction (closing this question pointing to that other one instead). But don’t worry, a question being closed is generally not a bad thing. Your question is sigue bien and will continue to lead people to the solution. -

2 Respuestas

You can't. Internally, they will be saved as a deletion and an addition. The display of "rename" will be calculated later and depends on that threshold.

respondido 09 mar '12, 23:03

To disable rename detection with TortoiseGit (though as being git-diff option, should apply to git by itself as well) I added the following line to gitconfig, which seems to do the trick (although based on documentation, I don't think it should):

  renameLimit = 1

Respondido 14 ago 14, 11:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.