22

I have a file 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 is being renamed to 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 %.

Thanks!

torngat
  • 635
  • 1
  • 5
  • 16
  • 4
    Is there a particular reason that it being logged as a "rename" is a problem? – Ry- Mar 09 '12 at 22:53
  • 6
    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? – torngat Mar 10 '12 at 19:39
  • @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 Jan 18 '16 at 16:10
  • @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 *still good* and will continue to lead people to the solution. – poke Jan 18 '16 at 19:40

2 Answers2

19

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.

Dominik Honnef
  • 17,937
  • 7
  • 41
  • 43
1

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):

[diff]
  renameLimit = 1
Gima
  • 1,892
  • 19
  • 23