Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make git ignore rename [duplicate]

Tags:

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!

like image 368
torngat Avatar asked Mar 09 '12 22:03

torngat


People also ask

Does git track renamed files?

Git keeps track of changes to files in the working directory of a repository by their name. When you move or rename a file, Git doesn't see that a file was moved; it sees that there's a file with a new filename, and the file with the old filename was deleted (even if the contents remain the same).

How do I get git to recognize a rename?

Git will automatically detect the move/rename if your modification is not too severe. Just git add the new file, and git rm the old file. git status will then show whether it has detected the rename.


1 Answers

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.

like image 104
Dominik Honnef Avatar answered Oct 11 '22 03:10

Dominik Honnef