Git commit that doesn't override original authors in git blame

微笑、不失礼 提交于 2019-11-27 03:46:00
Jay Paroline

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

It isn't the responsibility of the commit command to decide how to treat whitespaces, but the responsibility of the blame command because it is blame which analyzes the differences between versions to get the author of each line. So searching for an option to ignore whitespace in blame:

The option -w is defined as: "Ignore whitespace when comparing the parent's version and the child's to find where the lines came from." http://kernel.org/pub/software/scm/git/docs/git-blame.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!