Forcing all line endings to LF for git
Asked Answered
C

1

6

I develop for both Windows and linux. My Linux development environment is a virtual box running on my windows hosts. i have some directories shared (actually suing samba, not the built-in virtual box shared folders, so the directory is actually on the linux guest and shared up to the host)

We are moving from svn to git. I want to run Source Tree on my windows machine (the linux is headless) to do the version control. But I want all the files to have linux line endings (LF).

I tried following the instructions at Force LF eol in git repo and working copy but they aren't working for me.

I have set the config as follows:

[adamc@adamc-centos scripts]$ git config core.autocrlf
input
[adamc@adamc-centos scripts]$ git config  core.eol
lf

I have the following in my .gitattributes (even forced .sh to be text fioles and specified the eol again)

* text=auto
*.sh    text eol=lf

I have run the checkout-index command specified there, and I still have .sh files with windows line endings!

[adamc@adamc-centos scripts]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

[adamc@adamc-centos scripts]$ git checkout-index --force --all
[adamc@adamc-centos scripts]$ ./EWEB/get_unmerged.sh
-bash: ./EWEB/get_unmerged.sh: /bin/bash^M: bad interpreter: No such file or directory

What have I missed? Or am I approaching it wrong?

Cheroot answered 20/6, 2016 at 15:50 Comment(1)
core.eol is ignored if you set core.autocrlf to true or input git-scm.com/docs/git-config#Documentation/…Holsworth
T
-2

If you use different operating systems the recommended settings are

  • for windows $ git config --global core.autocrlf true

  • for linux/mac git config --global core.autocrlf input

I don't think you need to define parameter core.eol or use file .gitattributes. Git properly detects text files by default.

How to make commit that fixes all line endings in repository you can find at github page https://help.github.com/articles/dealing-with-line-endings

If you migrate your repository with git-svn probably it's good idea to rewrite the whole history and fix line endings in all commits.

Turro answered 20/6, 2016 at 17:12 Comment(1)
I want to check out on Windows but with linux line endings. As I understand it the default/recommended settings are to achieve the opposite: that you always have the native line endings for the place you check out.Cheroot

© 2022 - 2024 — McMap. All rights reserved.