Developers are permitted to change the value of the Git configuration variable using the “git config” along with the “core.autocrlf” variable value as the “<false>” command to avoid the previously discussed warning.
This guide will explain the method of changing the line-ending settings on Git.
How to Change Line-ending Settings?
To change line-ending settings on Git, try the below-given instructions:
- Navigate to the particular Git repository.
- Create and update the text file immediately.
- Track changes to the staging area.
- Execute the “git config –global core.autocrlf “true/false”” command to change the line-ending settings.
Step 1: Move to Local Repository
First, run the “cd” command along with the desired repository path and move to it:
Step 2: Generate and Update File
Next, create and update the text file simultaneously by running the “echo“ command:
Step 3: Track Changes
Then, run the following command to stage all added changes to the Git staging index:
Here, when we tried to add all changes to the staging area, a “warning: in the working copy of ‘naz-test/file1.txt’. LF will be replaced by CRLF the next time Git touches it” showed up:
Step 4: Check Line-ending Settings
Then, run the “git config” command to view the default settings of the line-ending:
According to the below-given output, the value of the “core-autocrlf” is set as “true”:
Step 5: Change core.autocrlf Value
Next, change the value of the “core.autocrlf” “true” to “false” through the provided command:
Step 6: Ensure Changed core.autocrlf Value
After that, run the following command to ensure the changed value is added successfully or not to the configuration file:
It can be observed that the default value has been changed to “false” successfully:
Step 7: Add Changes
Lastly, execute the “git add .” command to track all added changes to the staging area:
As you can see, the changes are successfully tracked from the working area:
That’s all! We have effectively compiled the procedure for changing line-ending settings on Git.
Conclusion
To change line-ending settings on Git, first, move to the particular Git repository. Then, create and update the text file simultaneously. Next, track changes to the staging area. After that, change the line-ending settings, and run the “git config –global core.autocrlf “true/false”” command. This guide illustrated the procedure of changing the line-ending settings on Git.