5

This problem is driving me mad. Using Git with Github.

I'm working on one particular file using spaces instead of tabs. I always ensure that I change all tab indents to spaces. Diffs confirm that I've changed tabs to spaces. I commit and push the code (with other changes) and all is good.

Until, I git pull --rebase. Now, my file -- in parts -- has tabs replacing spaces! Note, this is on parts of the file that only I have ever edited and I always use spaces, not tabs.

It doesn't happen when I do a normal git pull, only on rebase.

Additionally, changes on other branches that are merged into the main integration branch are also OK. It's just happens on rebase of the integration branch.

Tim W.
  • 371
  • 4
  • 13
  • 3
    Are there any Hooks registerd? Or something configured in your $home/.gitconfig? There are option that can be set like whitespace=fix or something like this. You should watch out for this. Search for core.whiteapce in http://www.progit.org/book/en/Customizing-Git-Git-Configuration – Jens Peters Feb 08 '13 at 19:29
  • Yeah, no hooks. It's probably something with my IDE. Thanks! – Tim W. Feb 12 '13 at 14:02
  • 1
    If you are using Eclipse an EGit. Checkout the eclipse setting for EGit. It is possible to set the settings in there ;) – Jens Peters Feb 12 '13 at 15:24
  • I'm experiencing this issue as well, and I'm using vim as my editor, and pulling from the command line. – rroche Mar 18 '13 at 18:53
  • 1
    Check in your .git/info/attributes file. See if you have any settings in there that might effect that file. git attributes are often used for manipulating files after commit/before save and after checkout/before opening. http://git-scm.com/book/ch7-2.html – eddiemoya Apr 01 '13 at 04:57
  • For me it was the line `whitespace = fix` in my `~/.gitconfig` file. I commented that out and was good to go. That's what I get for copying and pasting dot files. – jingman May 29 '13 at 21:43

2 Answers2

7
git apply --whitespace=fix 

appears to make that happen during rebase.

Maybe set

[apply]
    whitespace = warn

in your gitconfig and see if it resolves your issue.

See also the "core.whitespace" setting for more.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
heurist
  • 101
  • 1
  • 5
0

This issue can be caused by line endings settings. You can configure your git using instructions here.

kravasb
  • 696
  • 5
  • 16