0

I am new to programming and have created a repository on Git. I am trying to add my project folder to Git repo. In order to that, I am using the following set of commands:

   git init
   git add .
   git commit -m "message"

However, on performing "git commit" I am getting env: bash\r: No such file or directory. I tried to search for a solution and found this: https://github.com/clean-docker/Magento2/issues/27. Even after performing the steps mentioned in the link. It is not working for me.

Attached is the screenshot for reference. enter image description here

I posted this question before and it has been marked as duplicate but I am not able to resolve it with the solution provided on Stack overflow. Please help and put comments if you need more information.

Meiswjn
  • 752
  • 6
  • 17
  • 1
    Some of your script file(s) have DOS/Windows-style line endings (see [this question](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings)). I can't tell you which file(s), and I'm not familiar enough with `git`'s inner workings to even guess, but one way or another you'll have to track down the damaged file(s) and fix it/them. – Gordon Davisson Aug 16 '20 at 18:32
  • @GordonDavisson- I tried doing:: brew install dos2unix # Installs dos2unix Mac find. -type f -exec dos2unix {} \; # recursively removes windows related stuff but this also doesn't work for me. – Sharad Sawhney Aug 16 '20 at 22:38
  • 1
    Does the repository have any hooks like `pre-commit`, `commit-msg`, or `prepare-commit-msg`? The hooks could be installed in `$(git config core.hookspath)` or `.git/hooks`. They may have wrong line-endings. – ElpieKay Aug 17 '20 at 03:38
  • Rather than blindly running `dos2unix` on files in hopes of fixing something, use the `file` command to check the format of files. If it lists anything "with CRLF line terminators", you have a suspect file. At that point, try to determine if that particular file is *supposed* to have CRLF line terminators, and if not, *then* run `dos2unix` on it. – Gordon Davisson Aug 17 '20 at 08:03
  • Does this answer your question? [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – tripleee Aug 17 '20 at 17:08
  • @ElpieKay- Yes, it has all the hooks you mentioned. – Sharad Sawhney Aug 18 '20 at 15:03
  • @GordonDavisson- The question here is which file, we do not know which file is giving trouble and there are n numbers of file. – Sharad Sawhney Aug 18 '20 at 15:16

0 Answers0