Unix-style line endings are being converted to windows-style (CRLF) line endings when Git checkout is performed on Bamboo Windows elastic agent
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Unix-style line endings in files are being converted to windows-style (CRLF) line endings when Git checkout is performed on Bamboo Windows elastic agent.
Environment
- Windows elastic agent
- Git for Windows
Cause
The default value for Git for Windows for core.autoclrf
is true after installation. Bamboo stock elastic images use the default for the Git for Windows installer. This means that when a Git checkout is performed on a Windows machine the LF line endings are converted to CRLF.
Solution
If this is not desirable there are a few options:
Option 1:
Configure a custom Bamboo elastic agent image with core.autoclrf
set to false
globally before snapshotting it:
- Creating a custom elastic image - Windows
- http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace
Option 2:
Set git config --global core.autoclrf false
in a Script task before the source-code checkout on builds that execute on Windows agents.
Option 3:
Add a .gitattributes
to your repository which controls line ending styles and end of line normalization through the text
and eol
attributes: