Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sourcetree line ending issue

I am getting a very strange whitespace issue.

I am working with a local copy of a WordPress site with the .git repo in the wp-content/themes folder so all changes to any theme are tracked etc.

When I set up the repo it considered every file (apart from those in gitignore) as new files and I committed those as the 'initial commit'.

Firstly is that normal? To have to commit all the files when setting up a new repo? 2nd - and this is the strange behaviour.

when I go to stage these files I get some whitespace inserted after the first character on many of the files.

enter image description here

I am thinkng this si something to do with line endings. I have my global config set to autocrlf = true also I have tried

 autocrlf = true
 eol = native

In my local git config. .gitattributes is set to :

* text=auto

as advised by Force LF eol in git repo and working copy

Nothing is helping so far. I am working on a windows machine, but the files were tarred from a linux server and just untarred into the directory.

like image 582
user1683285 Avatar asked Sep 08 '14 13:09

user1683285


People also ask

How should git treat line endings?

This is a good default option. text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. text eol=lf Git will always convert line endings to LF on checkout.

What is default line ending?

If a new file is created the line ending will start with the system default: CRLF for Windows, LF for Mac and Linux, and CR for old-style Mac files. If a file contains multiple line-ending types it will display Mixed .


1 Answers

Goto terminal and enter:

git config --global core.autocrlf false

Then try to stage again.

I susepct it is the same issue as this one

Caused by git attempts to automatically converts your line ending style to CRLF when you checkout a file and back to LF before sending it.

You can safely disable it and take care of line ending problems yourself or convert line ending style for the file in question by yourself but latter only hide the problem.

Also, you will always have to have an initial commit for each new repo, since new repo (not cloned but created with git init, for example) does not contain any file, therefore you will have to specify which files you would like to track by making an initial commit.

For the space after first character issue, try to fix them manually and see if the problem reappears.

like image 110
8749236 Avatar answered Oct 04 '22 23:10

8749236