Question

I'm going to post this, then post the answer since it drove me crazy until I figured out the issue.

When installing symfony/symfony via composer, the process was repeatedly aborting due to this error:

[RuntimeException]                                                                                                                        
  Failed to execute git checkout 'fc0a09a2052e9275c16b5ab7af426935fe432f39' && git reset --hard 'fc0a09a2052e9275c16b5ab7af426935fe432f39'  

  error: Your local changes to the following files would be overwritten by checkout:                                                        
    src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf                                                                 
  Please, commit your changes or stash them before you can switch branches.                                                                 
  Aborting   

I know it has something to do with git changing whitespace or line-endings on clone, then when it tries to checkout the specific commit, it fails since the line-endings have now been changed. git config core.autocrlf input didn't help.

Was it helpful?

Solution

In ~/.gitattributes I had this line:

* text=auto

Removing it and ensuring core.autocrlf is set to "input" or "false" will fix this issue.

FWIW, I'm on a Mac and I've had similar issues with Homebrew that I'm hoping this fixes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top