1

I'm having a little trouble, since I like my code indented by tabs (yes some of you won't like it but keep on reading). I've accepted that it is the best to store files on git indented by spaces, since some people will have their tab settings set on different sizes and storing the files tabbed will mess up the indention. So far so good. Now to my problem.

I read about the filter feature of git and thought, prefect this will allow me to store my files indented by tabs but push them indented by spaces so no one is annoyed. At first this worked but then I noticed that even though I didn't changed the file itself it is reported as modified (by git status) since the indention characters are changed (of course). This is definitely not good.

Is there a way to get this that the files are somehow filtered but git status won't show them as modified just because of the filtering? (like somehow only applying the filter when pushing and fetching and let the filed be indented by tabs in the local repo)

Having to indent by spaces is annoying but having git status report all files as modified even though they aren't sucks so I hope anyone of you has an idea how to workaround this.

With kind regards

Edit: Further Explanation: What I've done, is setting these two settings:

git config --global filter.tabspace.clean 'expand --tabs=4' and

git config --global filter.tabspace.smudge 'unexpand --tabs=4 -a'

afterwards I've set git to use this filter (by setting it in the .gitattributes file).

This results in applying the clean function everytime commit and applying the smudge function everytime I checkout. This results in this that I have the files spaced in my local working directory and tabbed in the repository. The downside of this (the effevt I definitely do not want) is that git status (and so git add -A or git commit -a) thinks the reindented files are modified and are adding all files to the commit which is very bad.

Edit2: This Question is definitely not about rewriting the git history, it is about either getting git status ignore the changes made only by the filter, or getting the filter working between local repo and remote repo instead of between local repo and working tree.

atticus
  • 138
  • 15
  • Does this answer your question? [How do I run a code formatter over my source without modifying git history?](https://stackoverflow.com/questions/53502654/how-do-i-run-a-code-formatter-over-my-source-without-modifying-git-history) – phd Feb 21 '20 at 22:37
  • Not exactly, I'm not trying to modify something in the commit history. (I've updated my initial post, that should clarify my issue and should explain my issue so that if can be reproduced) – atticus Feb 23 '20 at 14:00

0 Answers0