I have this rule set in my git config:
autocrlf = true
this is to avoid problems we've had where our designers (who use mac) can't open text files that have been saved by our dev team (who use a mix of mac and linux). One file in particular (which was created recently) is causing a problem: git thinks there's nothing to commit, but won't let me check another branch out.
$ git status
# On branch master
# Your branch is up-to-date with 'dreamhost/master'.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: script/resource_library/fix_mp4_moov.sh
#
$ git commit -a -m "line endings changed again"
warning: LF will be replaced by CRLF in script/resource_library/fix_mp4_moov.sh.
The file will have its original line endings in your working directory.
# On branch master
# Your branch is up-to-date with 'dreamhost/master'.
#
nothing to commit, working directory clean
$ git pull
Already up-to-date.
$ git push
Everything up-to-date
$ git checkout feature/my_classes_v2
error: Your local changes to the following files would be overwritten by checkout:
script/resource_library/fix_mp4_moov.sh
Please, commit your changes or stash them before you can switch branches.
Aborting
So, cmon git, is it changed or not? make your mind up. Using cat -v on the file doesn't reveal any special line ending characters:
$ head -3 script/resource_library/fix_mp4_moov.sh | cat -v
#!/bin/bash
VIDEO_DIR=$1
Can anyone tell me how to set this straight? thanks, Max
EDIT - if i go into the file in vim and do set ff=mac, then i can commit this in and push it up. But, that breaks it for me - i can't run it because the shebang line isn't parsed properly by bash.
EDIT 2 - git diff results.
$ git diff script/resource_library/fix_mp4_moov.sh
warning: LF will be replaced by CRLF in script/resource_library/fix_mp4_moov.sh.
The file will have its original line endings in your working directory.
Simply setting core.autocrlf=true is not some magic bullet. All you have done is to keep all the data in the repository (with a mismatch of line endings) the same, but now you've made a promise to Git that the data in the repository has normalized line endings of \n.
Of course, this isn't true, because the repository still has the same mismatch of line endings it did before you set core.autocrlf=true.
You will need to normalize your line endings in the repository for everybody's sanity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With