Inércia Sensorial

23 de September de 2013

Replace tabs by space on git history

Filed under: Perils of Software Development — Tags: — inerte @ 21:04

So, I prefer spaces, and when I press tab, it should instead write 4 spaces. I forgot to set this option on Sublime Text and did some commits with tabs. The following git command will rewrite the repo history and replace tabs by 4 spaces.

git filter-branch --tree-filter 'git diff-tree --name-only --diff-filter=AM -r --no-commit-id $GIT_COMMIT | find . -exec perl -pi -e "s/\t/    /g" {} \;' HEAD

Powered by WordPress