0

I added and commited a branch locally (in a Docker container mounted as volume and locally in Windows).
The file contained tabs which had a width of 2 spaces. (they had two spaces in neovim and in Visual Studio Code)
Then I pushed that Branch onto gitlab.
And in gitlab the tabs I added to that file had a width of 8 spaces.

I tried using the autocrlf option in .gitconfig but it did not seem to have an effect.

I did the add and commit inside the Docker container.
But the git push I had to do in gitbash because of authentication issues.

Since I still see two spaces in my local file and in the Docker container it must be the git push from gitbash that changed the tabwidth.

torek
  • 448,244
  • 59
  • 642
  • 775
theerrormagnet
  • 174
  • 2
  • 15
  • 1
    I would guess that what the file contains is a literal tab character, and you have your local configuration set to display tabs with a size of 2, while on gitlab it's configured to show then as 8. However, there are configurations in Git to automate tab/space conversion, maybe you have one of them enabled? See https://stackoverflow.com/q/2316677/3216427 – joanis Feb 01 '22 at 22:25
  • 1
    Note that [tag:docker] is irrelevant and tag [tag:tabs] is for browser-style tabs, not `\t` characters. The tag [tag:tabstop] is the only SO tag for this that I can find. Git itself doesn't do tab expansion: that's up to your display devices. GitLab, since it's acting as a display device when it produces HTML, does have to do tab expansion. – torek Feb 02 '22 at 08:08

1 Answers1

0

joanis answer was correct and led me to the solution.

I solved the issue by adding the set expandtab to my .vimrc which converts tabs into the number of spaces you set with set tabstop and set shiftwidth.
So I can do in vim and it produces actually two spaces instead of a real tab.
If I don't use set expandtab the tab is only 2 spaces wide, but it still is a tab and behaves differently in gitlab.

theerrormagnet
  • 174
  • 2
  • 15