2

I am new to Git. I forked a repo, created a branch, made some changes, committed and then when I push (git push origin master), I get the following error :

     Starting Pattern Checks

    .gitattributes --> Please make sure all files only have LF endings (no CRLF).
     core/templates/dev/head/dashboard/notifications_dashboard.html --> Please use spaces instead of tabs.

     (41 files checked, 2 errors found)
     FAILED   Pattern checks failed
     Push failed, please correct the linting issues above

I am running git on Windows 7. Can anyone please help me ? Thanks.

PS: I went through this and this

UPDATE : The 'Please use spaces instead of tabs.' error was corrected by converting TAB to Spaces in 'Edit->Blank Operations->TAB to space' for Notepad++.

Community
  • 1
  • 1
user2125722
  • 1,289
  • 3
  • 18
  • 29

2 Answers2

2

The error means that the project requires Unix-style line endings (LF). However, you are using Windows-style line endings (CRLF). All decent programming text editors and IDEs have an option to set this. Editors also have an option to quickly replace all CRLF sequences with just LF. You need to find out how to do this in yours.

I also suggest that you learn about branching in git. If you are contributing to a larger project, it will be required that you create a new branch for each related set of changes that you want to make. Committing directly to master is seriously frowned upon.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
1

In Notepad++, go to the View menu > Show Symbol > Show End of Line. now press CTRL + H, make sure the Extended search mode is selected, and replace all \r\n with \n

Save. now try.

enter image description here

P.S: as Bergi also suggested, you may also automate both of your requirements via notepad by going to:

the Edit Menu>Blank Operations> Tab to Space

the Edit menu>EOL Conversion> UNIX/OSX Format

Stavm
  • 7,833
  • 5
  • 44
  • 68
  • The few files in the repository show LF already as line endings when I click "Show End of Line" in Notepad++. Also, how do I check if all files in my repository have LF endings ? – user2125722 Aug 18 '16 at 18:31
  • 1
    Much simpler than a custom search&replace: Edit menu > Line endings > Convert to LF – Bergi Aug 18 '16 at 18:33
  • like Bergi said in the comments, make sure core/templates/dev/head/dashboard/notifications_dashboard.html has no tabs in it, only spaces. – Stavm Aug 18 '16 at 18:34
  • @Bergi I converted the tabs to spaces by going to Edit -> Blank Operations -> TAB to Space and then tried pushing again. The second error has been solved. But the 'Please make sure all files are LF endings' error still persists. – user2125722 Aug 18 '16 at 18:39