Tag: indentation

Can git be told to use spaces in ~/.gitconfig?

When I use git config –global <some option> <some value>, Git will write the relevant entry in my ~/.gitconfig, indented by one tab. Since my ~/.gitconfig is version-controlled and I want it to not be a mess, I then have to go in by hand and replace the tab with spaces. Can Git be told […]

Git unstage lines where the only changes is white-space?

I have a source code file that for some reason have ended up with mixed indentation (spaces and tabs used for indentation). I have made quite a few changes and now I wish to commit those changes in git. Unfortunately I by accident instructed my editor to fix all indentation. So now it looks like […]

Convert spaces to tabs in lines I changed in a commit

I have made quite a big commit to a git repo (60 files changed, 1635 insertions(+), 3 deletions(-)) and now I realized I used spaces for indentation, while the rest of the code uses tabs. So, I want to replace spaces for tabs, but only in the lines that were changed by that commit, because […]

Integrate indentation & content changes in Git during merge: Best practices?

I’m using Git to track some matlab code. A toy example best illustrates the problem. The project so far looks like this. C / A– \ B Contents of A are x=5 We make commit C, where the line is changed to x=6 We then make commit B, where our content becomes as below if […]

Indenting Bash Script Output

I am attempting to write a bash script and I am having difficulty making the output look neat and organized. I could fall back on just using newlines, but I would much rather have output that was easy to read. For instance, when I run git clone …, I want to first echo “Cloning repository” […]

How do you make Git ignore spaces and tabs?

I have a small scripting project that consists of five different source files in one directory called “Droid XX-XX-XX”. Each time I created a new backup copy of the source directory, I put the date in the X’s. So there are about 15 different versions from different dates. I want to add each of these […]

How to handle widespread code format changes in a git repository

We have a project with around 500,000 lines of code, managed with git, much of it several years old. We’re about to make a series of modifications to bring the older code into conformance with the developer community’s current standards and best practices, with regards to naming conventions, exception handling, indentation, and so forth. You […]

Why is indentation in empty lines bad?

Every FOSS project I know has rules against trailing whitespace in code. But I think it’s very natural to continue the current indentation on the next line: int main() { ….int a = 42; …. ….return a; } But git for instance throws warnings anyway. So my question is: Why are those tabs inside the […]

Git Diff Indent/Pretty Print/Beautify Before Diff

Is there a way to make Git indent/beautify/pretty print two versions of C++ source files before diffing them? I think my goal is obvious: I don’t want Git to show me the myriads of changes introduced by some stupid IDE after some monkey (like me) has hit auto-format. Example usage: I hit git difftool –indent-before-diffing […]

Can git automatically switch between spaces and tabs?

I use tabs for indentation in my python programs, but I would like to collaborate (using git) with people who use spaces instead. Is there a way for git to automatically convert between spaces and tabs (say, 4 spaces = 1 tab) on pushing/fetching? (similar to the CR/LF conversion)

Git Baby is a git and github fan, let's start git clone.