I work on a project with a few other developers. Not everybody uses the same IDE. Recently I realized that some parts of code are indented with tabs and some with spaces. Everything looks OK when using tab = 4 spaces to display code, but it gets really messy with other settings.
We are using git as VCS.
Is there any way to reformat entire code in repository, commit those changes AND preserve “blame information” somehow?
No, that’s not possible without rewriting history.
The easiest and most developer-friendly solution (which won’t preserve blame information though) is fixing all whitespace issues in a single commit and then configuring git to reject commits adding mixed whitespace.
If rewriting history is not an issue for you (e.g. because you can ask all developers to throw away their local branches and fetch the rewritten ones), you could probably use
git filter-branchto fix whitespace in all commits. This will not a new commit and thus ensuregit blameshows correct information after the change.