Tab-size in files on Git - github

In my sublime by defoult I have Tab-size:2, and all code looks good, but when I push it to the repo - my code became unreal for read, it has huge indents.
Is this normal, or I something missed?

You should be able to avoid this using spaces instead of tabs. Set translate_tabs_to_spaces to true. See Indentation Settings for details.

Related

Code indentation messed up after pushing to github

The code indentation looks absolutely fine in my Xcode. But when I push it to github, it screws up the indentation
Does anybody know why? The weird thing is everything looks fine in Xcode. I tried to change Xcode Preferences, Ctrl + I, but none of them works. Any help would be appreciated. I'm using Xcode 10.1 and here are my Preferences Settings
Weirdly enough, in Xcode Preferences, switching Prefer indent using to Spaces and switch it back to Tabs seems to fix the issue
You can set indentation per file, group, project, see how to change your indentation settings here https://stackoverflow.com/a/47023275/1845432
It works for me
After changing your indentations settings, don't forget to reformat your files to apply the change.
⌘+a: to select all
Ctrl+i: to fix code indentation
I have it like this below and it works just fine with github.

Code pushed or uploaded to GitHub shows extra whitespace

Whenever I push or manually upload code to github extra whitespace will appear in the committed code. I'm using prettier and eslint, I've tried pushing with both enabled and disabled, and with prettier only enabled.
Code as shown on GitHub:
User Settings:
Workspace Settings:
Do you use tabs instead of spaces? Most editors allow you (like you’ve shown) to customize what a tab character shows as (e.g. 8 spaces). My assumption is that your setting is smaller than what GitHub uses for its display. GitHub doesn’t modify your code.
so setting "prettier.useTabs" to false resolves the issue, you would think that the code being pushed and code being displayed would be the same perhaps this is an issue to push to prettier's git repo but i digress, thanks for the feedback.

Indentation issue after pushing code from Brackets Editor to Github

For my code I'm using Brackets. In editor, code looks proper but after pushing it to github repository, indentations are messed up.
I'm using tab key to make indentation but in preferences there is set "use 2 spaces" after pressing tab key.
I've find out that Github is using 8 spaces for recognised tab keys. But still, it does not give me anything.
The biggest problem is when I use "one var statement".
I've also used jsbeautifier and it doesn't help me at all.
Here you can find an example: My Github code example
Does anybody had such a problem with brackets and github indentations?
Yes I had such problems.
These problems did not reappear when we moved to eslint inside of our IDE. The setup varies for each IDE. You can refer https://eslint.org/docs/rules/indent
If setting eslint is hard for you. Try bracket extensions like https://github.com/brackets-beautify/brackets-beautify . When used correctly it will beautify on save. Caution: Dont beautify code written by others or a team.

Strange indenting for Java Eclipse project on Github

Everything is good in Eclipse, indenting is fine. Then I put my code on github
and for some reason the indenting was a mess. I am not sure what is going on?
Thanks
If those indentation issues are reflected back in your code after a git push to GitHub, you either have:
a hook removing spaces before tab (as in "Make git automatically remove trailing whitespace before committing")
or a filter content driver declared ina .gitattributes file (as in "Can git automatically switch between spaces and tabs?")
Those are the two automatic mechanisms that could explain a change during the git commit.
But if your code looks fine locally after the git push, but looks not fine on GitHub, then you must have a combination of space and tabs correctly rendered locally, and rendered differently on GitHub.
As mentioned in "Indentation issue using sublime text 2":
The problem is not hard tabs, the problem is mixing spaces and tabs for indentation.
I got this working in eclipse:
Eclipse Settings:
Preferences : Java -> Code Style -> Formatter
Create new profile
Update profile indent settings:
Update Existing Java Source:
(Toolbar) Source : Correct Indentation
Check file, you should see all indentations use spaces, not tabs

Indentation issue using sublime text 2

I have the following problem.
I use ubuntu 12.04 and sublime-text-2 or gedit.
Sometimes i copy/paste something in a haml/ruby file, i indent it at 2 spaces, but when i push it up to github, the indentation is all wrong and not only the part I've copy/pasted. In my editor looks good.
If I open the file with LibreOffice/LeafPad the identation is like on github, but i wanna have it working on ST2.
Any suggestions?
To have correct indent across the service you should not use hard tabs
http://opensourcehacker.com/2012/05/13/never-use-hard-tabs/
You can achieve this functionality in Sublime Text 2 with a tab policy setting:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings
Also not that you might need to choose new policy for existing files from View > Indentation menu.
You can also mass-convert existing files away from tabs.
With Sublime Text 2:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Converting_existing_files_to_use_spaces_instead_of_tabs
... or batch convert the whole project:
http://miohtama.github.com/vvv/tools/expandtabs.html