Git commit and push is adding a line break at the end

Viewed 123

I need your wise help in understanding why when I commit and push something to Git, both my Terminal and GitHub CLI, it adds a \n at the end of the file.

This messes up things because it's a token that is being passed, and adding a line breaks things.

When I commit and push it from GoLand (IDE), this doesn't happen.

Any clues why?

1 Answers

Check first the value of (in command-line, outside of your IDE)

cd /path/to/local/repository
git config core.autocrlf

I recommend setting it to false, making sure that Git is not changing anything on checkout or commit.

And in Goland, activate the option "Warn if CRLF line separators are about to be committed".
That way, you will be notified if the same would ever occur in the IDE.

Related