Git commit在git blame中不会覆盖原作者 [英] Git commit that doesn't override original authors in git blame

查看:163
本文介绍了Git commit在git blame中不会覆盖原作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了perl脚本来修改php git存储库中的所有制表符,并将它们全部更改为4个空格。

  $ find -iname \ * .php -exec perl -pi -es / \ t / / g{} \ 

我可以使用 git commit 来提交此更改,但它会将我标记为<$ c $内所有更改行的作者c> git blame 。



有没有什么方法可以实现这种大规模的改变,但并不会将我标记为作者改变的线条,但保留原作者?这是我们不想在我们的项目中丢失的很多历史。



我们用4个空格替换标签的目的不是为了让事情在git blame中看起来不同,但要遵循适当的PEAR编码标准。例如。没有标签,请使用4个空格作为缩进。

感谢wnoise on git:改变样式(空白)而不改变所有权/责怪?,我想出了这个来运行任意过滤器在git的历史上,所以使用它你可以重写历史记录,使它看起来像是有问题的空白或者其他问题从未被提交过,留下了原作者,但你的代码被清理了: git filter-branch --tree -filter'git diff-tree --name-only --diff-filter = AM -r --no-commit-id $ GIT_COMMIT | php cleanup.php'HEAD


I've used a perl script to modify all tab characters in a php git repository and changed them all to 4 spaces.

$ find -iname \*.php -exec perl -pi -e "s/\t/    /g" {} \

I can commit this change with git commit, but it will mark me as the author of all changed lines inside git blame after this commit is made.

Is there any way to commit this massive change that doesn't mark me as the author of the changed lines, but retains the original author? That's a lot of history we don't really want to lose in our project.

Our purpose in replacing tabs with 4 spaces is not to make things appear different in git blame, but to follow proper PEAR coding standards. E.g. no tabs, use 4 spaces for indentation.

解决方案

Thanks to wnoise on git: change styling (whitespace) without changing ownership/blame?, I came up with this to run an arbitrary filter on git history, so using this you could rewrite history to make it look like offending whitespace or other issues were never committed, leaving the original authors in tact but your code cleaned up: git filter-branch --tree-filter 'git diff-tree --name-only --diff-filter=AM -r --no-commit-id $GIT_COMMIT | php cleanup.php' HEAD

这篇关于Git commit在git blame中不会覆盖原作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆