Tag: indentation

Show 2-space indents as 4-space in the editor

Suppose a Git repository contains sources with 2-space indents. I want they to be displayed as 4-space indents in VSCode or to be converted to 4-spaces in local repo but pushed back to the server with 2-indents.

Any tools rebase a branch in Git while running go fmt each commit separately?

I wish to rebuild/rebase all commits in a Git branch X using a source code formatting tool like go fmt or indent. I’d expect the workflow to roughly consist of making a new branch off master and iterating the following with $_ ranging over the commits in X: git cherry-pick $_ go fmt … git […]

Tell Git to ignore a file's whole contents moving down one line

I grow weary of scrolling through massive change lists when someone simply added a new line to a file, and didn’t actually change any characters/code. Is there any way to tell Git to ignore changes that only relate to additional empty lines, rather than characters? So with this file: /* My file */ a line […]

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 […]

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