简体   繁体   English

请问github或sourcetree忽略移动的行?

[英]ask github or sourcetree to ignore moved lines?

I'm using Git to keep track of the changes I make to my project. 我正在使用Git来跟踪我对项目所做的更改。 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). 当我使用Sourcetree和GitHub为OSX查看差异时,它会向我显示那些已移动的行被删除(并将其显示为其他地方的新行)。 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? 如何指示Sourcetree或GitHub忽略移动的行,如果它们真的消失了,则只显示删除的行?

Short answer, you can't. 简短的回答,你不能。

If you don't like default diffs calculated by git, you can try to use --patience (Generate a diff using the "patience diff" algorithm.) and --histogram (Generate a diff using the "histogram diff" algorithm.) options of git diff . 如果您不喜欢由git计算的默认差异,您可以尝试使用--patience (使用“耐心差异”算法生成差异)和--histogram (使用“histogram diff”算法生成差异)。 git diff的选项。

Also this might help Customizing-Git-Git-Attributes#Binary-Files see Diffing Binary Files. 这也可能有助于Customizing-Git-Git-Attributes#Binary-Files看到Diffing Binary Files。

An alternative is to use the command line. 另一种方法是使用命令行。 You can instruct git to try and guess when lines of code have been moved 您可以指示git尝试猜测何时移动了代码行

git blame -M -w <file>

should show you the author and sha1's of what it thinks are the original authors of those lines. 应该向你展示作者和sha1的思想是这些行的原作者。 It's an educated guess, so it might be wrong sometimes. 这是一个有根据的猜测,所以有时可能是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM