When I moved my Laravel development environment from Ubuntu to Windows 11, I started encountering something unfamiliar while working with Git.

I was staging my Laravel project changes using:

git add . 

Instead of a completely clean output, Git displayed this warning:

warning: in the working copy of 'database/migrations/2026_11_28_165714_add_unique_constraint_to_dining_areas_table.php', LF will be replaced by CRLF the next time Git touches it 

Initially, I wondered whether something was wrong with my Laravel migration or Git repository.

However, after understanding the message, I discovered that this was not an actual error. It was a warning about differences in how Windows and Linux handle line endings.

In this article, I will explain what LF and CRLF mean, why Git displays this warning, and how to configure Git correctly on Windows.

1. What Are LF and CRLF?

Computers need a way to identify where one line of text ends and another begins.

Different operating systems traditionally use different characters to represent the end of a line.

There are two common line-ending formats:

LF (Line Feed)

  • Represented by \n.
  • Commonly used by Linux and Ubuntu.
  • Also used by macOS.

CRLF (Carriage Return + Line Feed)

  • Represented by \r\n.
  • Commonly used by Windows.

Here is a simple comparison:

Operating system Line ending Representation
Linux / Ubuntu LF \n
Windows CRLF \r\n
macOS LF \n

Although these formats perform the same basic function, they are represented differently internally.

2. Why Was Git Displaying This Warning?

To understand the warning, consider my development environment.

I previously used Ubuntu for Laravel development before migrating to Windows 11.

When working across different operating systems, Git needs to manage differences in file formatting.

For example:

  1. A developer creates a PHP migration file on Ubuntu.
  2. The file uses LF line endings.
  3. The developer opens the same project on Windows.
  4. Git detects the difference between the file's line endings and the configured Windows checkout behaviour.
  5. Git displays a warning indicating that LF may be converted to CRLF the next time it updates the working copy.

This is why I received:

LF will be replaced by CRLF the next time Git touches it 

The important thing to understand is that Git is warning about file formatting, not PHP syntax or Laravel functionality.

3. Understanding Git's core.autocrlf Configuration

Git provides a configuration option called core.autocrlf.

This setting determines how Git handles line endings when checking out and committing files.

There are three common configurations.

Option A: core.autocrlf true

git config --global core.autocrlf true 

This is a common configuration for developers working on Windows.

It tells Git to:

  • Convert LF to CRLF when checking out files on Windows.
  • Convert CRLF back to LF when committing files.

This helps maintain LF line endings in the repository while allowing Windows developers to work with CRLF in their local files.

Option B: core.autocrlf input

git config --global core.autocrlf input 

This tells Git to:

  • Convert CRLF to LF when committing.
  • Avoid converting LF to CRLF during checkout.

This is useful when you want LF line endings in your working directory, even when developing on Windows.

Option C: core.autocrlf false

git config --global core.autocrlf false 

This disables Git's automatic line-ending conversion.

Git will generally leave line endings unchanged.

This can be useful when a project explicitly manages line endings through other mechanisms, such as .gitattributes.

4. How I Fixed the Warning on Windows 11

For my Windows development environment, I chose the first option.

I opened PowerShell in my Laravel project directory and executed:

git config --global core.autocrlf true 

To verify the configuration, I ran:

git config --global --get core.autocrlf 

Git returned:

true 

This confirmed that automatic line-ending conversion was enabled.

Note: Changing this configuration does not necessarily rewrite existing files immediately. It controls how Git handles line endings during subsequent checkout and commit operations.

5. Continue Working with Git Normally

After understanding the warning, there was no need to recreate my Laravel migration or delete any project files.

I could continue with my normal Git workflow.

First, check the current repository status:

git status 

Stage the changes:

git add . 

Commit the changes:

git commit -m "Add unique constraint to dining areas" 

The important lesson is that a Git warning does not automatically mean something has failed.

Always understand the message before changing your project files.

6. An Additional Recommendation: Use a .gitattributes File

For teams working across Windows, Linux and macOS, relying only on individual Git configurations may not be enough.

A better approach is to define consistent line-ending rules inside the project.

Create a .gitattributes file in your repository's root directory.

For example:

# Automatically normalize text files * text=auto # PHP files should use LF line endings *.php text eol=lf # JavaScript files *.js text eol=lf # CSS files *.css text eol=lf # HTML files *.html text eol=lf # JSON files *.json text eol=lf 

This tells Git how to handle line endings for different file types.

It is particularly useful when multiple developers contribute to the same Laravel project using different operating systems.

If you introduce .gitattributes to an existing repository, you can normalize tracked files with:

git add --renormalize . 

Review the changes using:

git status 

Then commit the changes if everything looks correct.

7. Important Lessons for Developers

Moving from Ubuntu to Windows taught me that not every warning in a development environment indicates a broken application.

Here are some lessons worth remembering:

  1. Understand your tools: Learn what Git warnings mean before attempting to fix them.
  2. Understand operating systems: Windows and Linux have some differences in how they handle files.
  3. Configure Git properly: The core.autocrlf setting helps manage line endings.
  4. Use .gitattributes: It helps development teams maintain consistent formatting across different operating systems.
  5. Do not panic: A line-ending warning does not mean your Laravel application or database migration is broken.

Conclusion

Working across different operating systems introduces small challenges that developers may not encounter when using only one environment.

My experience moving from Ubuntu to Windows 11 reminded me that understanding the tools we use is just as important as writing application code.

The next time you encounter:

LF will be replaced by CRLF 

Remember that Git is talking about line endings, not necessarily reporting a problem with your code.