1

I'm using Git to keep track of the changes I make to my project. I often move entire sections around within my files.

When I view diffs using Sourcetree and GitHub for OSX, it shows me those moved lines as deleted (and shows them as new lines elsewhere). This is confusing visually.

How do I instruct Sourcetree or GitHub to ignore moved lines, and only show lines as deleted if they are truly gone?

4

2 回答 2

3

简短的回答,你不能。

如果您不喜欢 git 计算的默认差异,您可以尝试使用 git diff--patience的 (Generate a diff using the "patience diff" algorithm.) 和--histogram(Generate a diff using the "histogram diff" algorithm.) 选项。

这也可能有助于Customizing-Git-Git-Attributes#Binary-Files参见 Diffing Binary Files。

于 2013-07-03T08:00:26.043 回答
1

另一种方法是使用命令行。您可以指示 git 尝试猜测代码行何时被移动

git blame -M -w <file>

应该向您展示它认为是这些行的原始作者的作者和 sha1。这是一个有根据的猜测,所以有时它可能是错误的。

于 2014-01-29T18:31:33.860 回答