I am trying to format an entire repo using a code formatter tool. In doing so, I want to keep information about who committed which line, so that commands like git bla
git filter-branch --tree-filter "find < dir > -regex '.*.(cpp\|h\|c\|< etc >)' -exec < formatter-command > {} \;" -- --all
< dir >
: directory of concerned, since above needs to be run from the root dir, but you may want to format only certain sub-dir under the root git dir.
< etc >
: other file formats.
< formatter-command >
: the command which you can run for a single file and it would format that file.
--all
at the end means to do this for all git branches (overall 4 dashes)
E.g. this is what I have, wherein my git contains src directory (apart from tests, tools, etc)
git filter-branch --tree-filter "find src -regex '.*.(cpp\|h\|cu\|inl)' -exec clang-format -style=google -i {} \;" -- --all
Above will rewrite each git commit, but not change the git annotation. Since this modifies git history, everyone would have to reclone once this is pushed.