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.