Skip to content

Unable to commit when git hooks use bash syntax. #10060

Closed

Description

@b-hayes

Describe the feature or problem you’d like to solve

Our project have git hooks that were written for Mac and Linux but I am in windows. WSL is my dev env and can run these hooks but Github desktop will not run any git commands in WSL behind the scenes.

Github desktop is unusable by many devs using WSL.

When a git hook is run via GitHub desktop we see:
Commit failed - exit code 1 received, with output: ''.' is not recognized as an internal or external command,
operable program or batch file.'

Also tried using bash as my shell.
Also tried adding "bash -c" etc into the git hooks that run but then I get "bash is not a recognized command" even tho it IS recognized by all my shells.

Proposed solution

Please add WSL integration || or actually use the shell to run already working git cli so that desktop is just an interface running git commands behind the scenes would be nice.

Additional context

Some context.. the hooks are php files with
#!/usr/bin/env php

Pinned by niik

Activity

  1. tierninho commented on Jun 24, 2020

    @tierninho
    Contributor

    @b-hayes Thanks for the issue. We added support for opening a WSL shell from within GitHub Desktop in #7821.

    Are you running into these issues with mac or Linux? We only support Mac on this channel. A former developer of GitHub Desktop maintains a fork with Linux builds available for download:

    https://github.com/shiftkey/desktop/releases

    We are also tracking official Linux support in #1525.

  2. added
    more-info-needed
    on Jun 24, 2020
  3. b-hayes commented on Jun 24, 2020

    @b-hayes
    Author

    I'm on windows, hence WSL question.

    I didn't see WSL option but from what you just said I think I misunderstood the shell integration options entirely.

    I thought it was using the shell environment to run git commands. Eg. my git hooks would work if WSL was an option.

    I am aware there is a Linux version and I could possibly run this via xserver from WSL itself as a convoluted workaround but then git hooks don't work on GitHub for Desktop in Linux either lol. (last time I checked).

    So I'm just out of luck it seems.

    But I do think this could fix a lot of things across all systems if the git commands were run in the user's shell of choice.

  4. tierninho commented on Jun 24, 2020

    @tierninho
    Contributor

    Oops, I totally blanked on the recognizing it was a Windows env, as I was thrown off with the Mac and Linux comment. 😝

    But I do think this could fix a lot of things across all systems if the git commands were run in the user's shell of choice.

    I do think you are in luck as I just spotted this: #8863 which was just released today!

  5. b-hayes commented on Jun 25, 2020

    @b-hayes
    Author

    Oops, I totally blanked on the recognizing it was a Windows env, as I was thrown off with the Mac and Linux comment. 😝

    But I do think this could fix a lot of things across all systems if the git commands were run in the user's shell of choice.

    I do think you are in luck as I just spotted this: #8863 which was just released today!

    I see that issue says "Fixed not being able to run the GitHub command from the WSL CLI" which is not what I am talking about.
    I meant that git commands are run in the user's shell behind the scenes to avoid all the issues.

    Example:
    In Github desktop, I click commit and it runs WSL "git commit -m \"the commit message\""

    Running git itself in the users chosen shell means it bypasses having to add special support for the bash syntax or detecting and running git hooks in the appropriate manner according to the shebang lines in the script.
    Doing it this way means what shell is installed or what version of bash.exe is used doesn't matter. The correct version of PHP or node or anything else needed to be run by a shebang line will be of no concern if native git command is run in the wsl ditrol.

    Just bypass all of it and use Github desktop to execute commands for you as if you were in the terminal.

  6. removed
    more-info-needed
    on Oct 20, 2020
  7. b-hayes commented on Mar 9, 2021

    @b-hayes
    Author

    Came back to GitHub Desktop as I miss it and nothing has changed. Github desktop is still useless to anyone using WSL.
    Git hooks do not run. Status is really slow takes ages for changes to appear in the window, and it often creates a file called 'NUL' inside your project whenever you do a commit. Then you have to keep deleting this file all the time. 🤦‍♂️

    Loving WSLv2 its a massive improvement but still can't use the Github desktop app 😢

  8. JohnCliffe commented on Jun 27, 2022

    @JohnCliffe

    added git hooks to WSL project so guess I need to move on from github desktop then?

  9. b-hayes commented on Jun 28, 2022

    @b-hayes
    Author

    added git hooks to WSL project so guess I need to move on from github desktop then?

    yeah pretty much. 2 years later and we still cant use github desktop with wsl at all.

  10. reopened this on Jan 14, 2026
  11. niik commented on Jan 14, 2026

    @niik
    Member

    Yesterday we shipped GitHub Desktop 3.5.5-beta1 to our beta channel with improved support for hooks related to committing.

    Screenshot showing the GitHub Desktop commit form as a pre-commit hook is running

    The support is experimental and currently limited to our beta channel. While we believe that this release resolved this issue we're looking for real-world feedback so if you have the ability we'd appreciate it if you could download our beta channel and give it a spin. Ensure the experimental hooks support it's enabled by going to Settings -> Git -> Hooks and making sure the "Load Git hook environment variables from shell" is ticked.

    Screenshot showing the hook settings dialog
  12. added
    triage
    and removed
    triage
    on Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions