Reputation: 189
Say I have a file, myfile.txt. It has a paragraph of text in it, and I copy it to a new file, myfile2.txt.
If I git diff, it will show myfile2.txt as a new file. Okay. Now I replace every occurrence of "the" with "hello" and commit.
The problem I'm having is that after the commit happens, git diff will show all of myfile2.txt as a new file and it will not show me that "the" has been replaced by "hello" everywhere (because as far as it's concerned everything is a new change).
Even if I first commit and push myfile2.txt prior to editing so that the changes are evident, that's not a good solution. It is a problem because if I squash commits down to a feature and commit it, myfile2.txt shows up as a brand new file, whereas I would like to see that those replacements have been made.
Does git have a feature that allows me to track changes in a file that was copied from another, such that a git diff will show me only those modifications and not the added file as a whole?
Upvotes: 3
Views: 3328
Reputation: 14091
I had a similar question recently about the issue of directory renames with similar advice.
There is also the --patience option to have a look at git-diff-patience.
Upvotes: 0