Issue
Postman is changing line endings when exporting a JSON collection file from CR LF (Windows) to LF (Unix) and this is a causing Warning when I try to commit the file to git.
Has anyone come across this before and is there a solution other than the work around that I outline below?
Specs
- Windows 10
- Postman version 8.0.3
- Notepad++ version 7.9.1
Steps to reproduce
Ensure Postman collection JSON file has CR LF (Windows) line endings using Notepad++ as shown in screen grab 1
Import Postman collection file to Scratchpad Workspace
Make a small change like rename a Request (this is automatically saved)
Export the collection and save/replace it back to the original file that was imported
Go back to Notepad++ and you will be asked to reload the file, which you "yes" to
Check that the Postman collection JSON file has now unexpectedly changed CR LF (Windows) line endings to LF (Unix) line endings using Notepad++ as shown in screen grab 1
Stage the file in git and you will see the Warning in screen grab 2. Note, I'm using Git Extensions here but you will see the same Warning on the command line.
.gitattributes
My .gitattributes file has the following entries:
* text=auto encoding=UTF-8
*.sh text eol=lf
*.service text eol=lf
- text=auto encoding=UTF-8 is setting the default behaviour of text/JSON files
Work around
To avoid the Warning, I have to do the following every time I want to change/export and git commit a Postman collection file, which I'm sure I shouldn't need to do. (A colleague of mine has the same behaviour when I checked on his machine).
After Steps to reproduce above, un-stage the file in git
Use Notepad++ to change the Postman file back from having LF (Unix) line endings to having CR LF (Windows) line endings using Notepad++
Save the file in Notepad++
Stage the file in git and the Warning will have gone
Screen grabs
Screen grab 1
Screen grab 2
Links
LF will be replaced by CRLF in git - What is that and is it important?
Windows git "warning: LF will be replaced by CRLF", is that warning tail backward?
https://github.com/postmanlabs/postman-app-support/issues/190
https://github.com/postmanlabs/postman-app-support/issues/726
https://github.com/postmanlabs/postman-app-support/issues/4179