I'm merging two branches in git, having a week worth of work each and some of the files were moved or renamed and modified.
Git seems to get the stuff completely wrong in some cases and it says file a was moved to file b when in reality they are totally unrelated.
I'm having quite a few such false positives (roughly 25%). I would like to influence the algorithm Git uses to figure out whether a file was moved, renamed or is new.
I know I read somewhere I can do the latter and I hope I can do the former too, but my googling skills are failing me today.
In Git's case, it will try to auto-detect renames or moves on git add or git commit ; if a file is deleted and a new file is created, and those files have a majority of lines in common, Git will automatically detect that the file was moved and git mv isn't necessary.
We use the git mv command in git to rename and move files. We only use the command for convenience. It does not rename or move the actual file, but rather deletes the existing file and creates a new file with a new name or in another folder.
In your repository, browse to the file you want to rename. In the upper right corner of the file view, click to open the file editor. In the filename field, change the name of the file to the new filename you want. You can also update the contents of your file at the same time.
I've noticed this too. I think "--find-renames=90" will be stricter than the default.
From the git diff documentation http://git-scm.com/docs/git-diff
-M[n] --find-renames[=n] Detect renames. If n is specified, it is a is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example, -M90% means git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed.
-C[n] --find-copies[=n] Detect copies as well as renames. See also --find-copies-harder. If n is specified, it has the same meaning as for -Mn.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With