Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 440
nookni Avatar asked Oct 15 '10 19:10

nookni


People also ask

Does git blame identify a particular commit?

The git blame command is used to know who/which commit is responsible for the latest changes made to a file. The author/commit of each line can also been seen.

How does blame work in git?

Summary. The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was. The output format of git blame can be altered with various command line options.

What is git blame ignore revs?

git-blame-ignore-revs . It expects one commit hash per line, and all commits in the file will be ignored by git blame . You can add comments to this file by prefixing it with a # , and I'd recommend commenting each sha to explain why it's being skipped. $ cat .git-blame-ignore-revs. # Upgrade to Prettier 2.0.

What is raw and blame in git?

The Raw, Blame, and History buttons appear when viewing a single file of a repository. For example, let's visit the README.md file by clicking on it: The Raw button, like the name suggests, opens the file in a raw form, meaning that any HTML formatting disappears.


1 Answers

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

like image 108
CodesInChaos Avatar answered Sep 19 '22 15:09

CodesInChaos