0

I am running docker for my Laravel application (BE). I have made a simple update on readmeme.md file and tried to commit & push this file to git.

When I try to commit it this is what I get.

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - docker: Error response from daemon: the working directory 'C:/Program Files/Git/var/www/api' is invalid, it needs to be an absolute path. See 'docker run --help'.

Specs:

  • Git: git version 2.38.0.windows.1
  • Docker version 20.10.17, build 100c701
  • My backend is Laravel
sme3x
  • 18
  • 5
  • Someone said I should look into `grumPhp` ( ./.git/hooks/)? But I have no idea what to look for. – sme3x Oct 10 '22 at 08:15
  • Why is committing triggering/executing Docker? Do you have any hooks set up? – knittl Oct 10 '22 at 08:21
  • I did not set up any specific hooks. Everything should be out of the box. If I can somehow "re-install" git or set it back to default I could do that. – sme3x Oct 10 '22 at 08:30
  • 2
    Hooks are (usually?) repository-specific. Check `.git/hooks` if it contains any references to docker or if any of the hook scripts are executable – knittl Oct 10 '22 at 08:31
  • Indeed file `commit-msg` does contain this piece of code. `# Run GrumPHP (cd "./" && printf "%s\n" "${DIFF}" | 'docker' 'run' '--rm' '-t' '-v' '$(pwd):/var/www' '-w' '/var/www/api' 'my_container_name' 'vendor/bin/grumphp' 'git:commit-msg' "--git-user='$GIT_USER'" "--git-email='$GIT_EMAIL'" "$COMMIT_MSG_FILE")` Should I remove everything after pipe? How should default commit script look like? – sme3x Oct 10 '22 at 08:36
  • 1
    Then you have set up a Git hook. You can either skip it during commit or you can remove the hook. But I assume it is there for a reason, so you must find out why you put it there in the first place – knittl Oct 10 '22 at 08:38
  • Thank you kind sir. I removed / edited this line and now it works. – sme3x Oct 10 '22 at 08:46

1 Answers1

0

The error message comes from a Git hook. Check the .git/hooks directory if you have set up any Git hooks that invoke Docker. Then find out, why you have them set up and if you need them (e.g. to contribute to a project while adhering to their coding guidelines).

If you don't need them, mark the file as non-executable or delete it. To ignore it for a single commit, pass --no-verify to git commit.

knittl
  • 246,190
  • 53
  • 318
  • 364