-1

I am a beginner in Git and GitHub.
There's an issue that I am facing.

I made changes in a separate branch and pushed them, but when I looked into the "Files Changed" section on GitHub, there were unnecessary indentations that weren't present in my editor (Atom).

Can anyone explain me why is it happening and what's the solution for this?

Thank You

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Azan
  • 19
  • 1
  • 7

1 Answers1

1

This isn‘t a Github or Git problem. That has to do with the text editor, in your case with atom and your coding style. Use either only tabs or only spaces for indentation.

If you use a tab in your code and your text editor atom shows a tab, as an example. as 2 spaces, it is still passing \t and not \s\s in your code. And tabs can display different on all platforms. So your text editor atom makes 2 spaces for one tab, and GitHub display tabs as 8 spaces. That‘s why looking different.

But you can configure your editor to insert either a literal tab character or some number of spaces, when you hit the tab key.

How you can change the indentation, you can look at this stackoverflow-question

phd
  • 82,685
  • 13
  • 120
  • 165
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
  • You can also change the way GitHub shows tabs in the diff by adding e.g. `?ts=2` to the diff URL https://stackoverflow.com/a/23522945/2066474 – rbennett485 Jul 12 '21 at 15:10