Py学习  »  Git

git重命名匹配是否可以忽略空白更改?

Schwern • 5 年前 • 485 次点击  

当我重命名一个文件并进行空白更改(例如更改缩进)时,git无法识别该重命名。我找不到 git diff 使其在查找重命名时忽略空白的标志。这使得审查其他简单的重构变得困难。

例如。。。

$ git init
$ ruby -e '100.times { puts "Basset hounds got long ears" }' > file
$ git add file
$ git commit -m 'first commit'
$ git mv file file2

现在一切都很好。

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    renamed:    file -> file2

现在,如果我缩进文件中的行,git将不再识别重命名。

$ ruby -i -pe 'gsub(/^/, "  ")' file2
$ git add .
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    file
    new file:   file2

在我承诺之后 git diff -w HEAD^ 仍然显示删除和新文件。我找不到 差异比较 将识别重命名的选项。

是否有一组选项允许git在检测副本和重命名时忽略空白?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/39846
 
485 次点击  
文章 [ 1 ]  |  最新文章 5 年前