Skip to content

Improve context on pre-commit hook failures and provide escape hatch #9351

Closed

Description

@j-f1

Describe the bug

I cannot commit to the excalidraw/excalidraw repo in GitHub Desktop. Using GitUp (another GUI) or the git CLI both work fine.L

Version & OS

GitHub Desktop Version 2.4.0, macOS Version 10.15.3 (19D76)

Steps to reproduce the behavior

  1. Clone https://github.com/excalidraw/excalidraw
  2. Run npm install to install the dependencies
  3. Open the repo in your favorite editor and delete lines 8–18 of src/index.tsx so you have something to commit.
  4. In GitHub Desktop, commit the change.

Expected behavior

The commit occurs successfully.

Actual behavior

An error dialog displaying this text:

Details
Commit failed - exit code 1 received, with output: 'husky > pre-commit (node v13.11.0)
Preparing... [started]
Preparing... [failed]
→ error: unknown option 'ignore-skip-worktree-entries'
usage: git update-index [<options>] [--] [<file>...]

[removed: listing of all options]

Cannot save the current worktree state
Running tasks... [started]
Running tasks... [skipped]
→ Skipped because of previous git error.
Applying modifications... [started]
Applying modifications... [skipped]
→ Skipped because of previous git error.
Cleaning up... [started]
Cleaning up... [skipped]
→ Skipped because of previous git error.

  ✖ lint-staged failed due to a git error.
  Any lost modifications can be restored from a git stash:

    > git stash list
    stash@{0}: On master: automatic lint-staged backup
    > git stash pop stash@{0}

error: unknown option 'ignore-skip-worktree-entries'

[removed: listing of all options]

Cannot save the current worktree state
husky > pre-commit hook failed (add --no-verify to bypass)

Additional context

I’m guessing this is because --ignore-skip-worktree-entries was recently added to Git and Husky is using Desktop’s bundled version for some reason?

Pinned by niik

Activity

  1. rafeca commented on Mar 26, 2020

    @rafeca
    Contributor

    Thanks for reporting @j-f1 !

    After some offline discussion with @j-f1 , he realized that the issue comes from the lint-staged npm package.

    These are the events that I think are happening based on the conversation with @j-f1 (I haven't been able to reproduce the problem in my machine though, so take this with a grain of salt):

    1. husky creates a pre-commit git hook, which gets executed by the version of git that gets bundled by Desktop.
    2. This pre-commit hook executes an sh script that ends up executing lint-staged on the excalibur/excalibur project (source).
    3. The pre-commit hook gets executed with the GIT_EXEC_PATH env variable set to the path of the git binary bundled in Desktop and adds its path to the beginning of the PATH env var.
    4. lint-staged runs git stash save --include-untracked --keep-index 'lint-staged automatic backup' (source).
    5. The git binary used for the previous command gets resolved to the system version of git (I have no idea why this happens??? lint-staged uses execa to execute git).
    6. If the system version of git is above v2.25.0, the git stash command will internally call git update-index --ignore-skip-worktree-entries -z --add --remove --stdin (source).
    7. Now, the git command will get executed using the git binary bundled in Desktop (thanks to the GIT_EXEC_PATH env var).
    8. The git binary bundled in Desktop is v2.23.1, which doesn't support the --ignore-skip-worktree-entries param so the command fails.

    Based on the sourcecode of git stash, looks like this behaviour can be avoided by using setting the stash.useBuiltin config param to false (this way, the old legacy stash logic will get executed):

    $ git config stash.usebuiltin false

    (this is just a potential workaround and may cause other issues).

    The main question here is regarding point 5., and why does lint-staged ignores the path and resolves to the system git binary in some systems. I think that if we can figure out that issue and resolve it, this issue will go away.

  2. added
    investigation-needed
    on Mar 26, 2020
  3. rafeca commented on Mar 27, 2020

    @rafeca
    Contributor

    I've confirmed with @j-f1 that git config stash.usebuiltin false fixes the issue, so this can be used as a workaround.

    It's still unclear why does lint-staged executes the system git binary in some systems. This could probably be caused by some specific bash configuration...

    Anyways, I see 3 different things going on here:

    1. There's an issue on git, which causes git to spawn internally a binary of a different version causing failures when using GIT_EXEC_PATH.
    2. The git version bundled in Desktop is a bit old, upgrading it to the latest one would fix that issue.
    3. Desktop doesn't have any escape hatch when such pre-commit issues occur, so users are helpless and need to fallback to the terminal.

    Maybe we can refocus this issue (or create a new issue) to try to address point 3. so:

    • Errors happening on pre-commit hooks are clear and as easy to understand as possible.
    • Desktop offers a way to "Commit anyways" when a pre-commit error happens.
  4. changed the title [-]Husky pre-commit failure[/-] [+]Improve context on pre-commit failures and provide escape hatch[/+] on Mar 27, 2020
  5. changed the title [-]Improve context on pre-commit failures and provide escape hatch[/-] [+]Improve context on pre-commit hook failures and provide escape hatch[/+] on Mar 27, 2020
  6. steveward commented on Feb 19, 2021

    @steveward
    Contributor

    Feedback from #11626, where the option to provide a "Commit anyways" option was requested:

    Describe the feature or problem you’d like to solve
    I love this app so much that I feel a sense of discomfort anytime I need to switch to my terminal to do something. In that spirit, one of the actions that still requires switching to the terminal is performing a commit that I know will fail the pre-commit hooks (ex: linting).

    Proposed solution
    Proposal I: Add Option to skip webhooks in commit form
    This could be a checkbox next to the "Add Co-Authors" Icon.

  7. billygriffin commented on Mar 15, 2021

    @billygriffin
    Contributor

    This came up again in #11802. If a contributor wants to take a crack at adding a "Commit anyway" button to the error dialog, I think that'd be a great next step.

  8. mosherc commented on Nov 12, 2021

    @mosherc

    Any movement on this?

  9. CodingSamurai commented on Nov 29, 2021

    @CodingSamurai

    Another vote for making this happen.

  10. jbvsmo commented on Dec 23, 2021

    @jbvsmo

    Why can't there be a button to "commit anyway" on the error window that uses --no-verify?
    That is a no brainer since this window only shows for people with pre-commit.

    I've been trying to move to github desktop from another gui tool, but I guess I might have to find yet another option

  11. added a commit that references this issue on Jan 28, 2022
  12. mchammer01 commented on Feb 1, 2022

    @mchammer01

    A ➕ to make this happen

  13. bernardobarreto commented on Feb 17, 2022

    @bernardobarreto

    A ➕ to make this happen [2]

  14. ikhurramraza commented on Apr 25, 2022

    @ikhurramraza

    A ➕ to make this happen [3]

  15. james70s commented on Apr 26, 2022

    @james70s

    A ➕ to make this happen [4]

  16. 24 remaining items

  17. JonasJore commented on Aug 20, 2024

    @JonasJore

    Is this feature going to happen? It would be really nice 💯

  18. modelrailroader commented on Aug 24, 2024

    @modelrailroader

    A ➕ to make this happen [21]

  19. thibaut-pro commented on Aug 29, 2024

    @thibaut-pro

    A ➕ to make this happen [22]

  20. shubham-wynk commented on Sep 12, 2024

    @shubham-wynk

    A ➕ to make this happen [23]

  21. shubh710 commented on Sep 12, 2024

    @shubh710

    @steveward I would love to pick this up, request you to assign this to me.

  22. jmechamFD commented on Sep 12, 2024

    @jmechamFD

    I see most of the discussion in this is about commit hooks, just want to suggest push hooks should have this feature as well.

  23. alvarohulse commented on May 22, 2025

    @alvarohulse

    This came up again in #11802. If a contributor wants to take a crack at adding a "Commit anyway" button to the error dialog, I think that'd be a great next step.

    @billygriffin Is this option still available? I'd assume so, but 2 things make me wonder:

    1. It's been 4 years, lol.
    2. I saw a somewhat similar PR (Create --no-verify checkbox) closed out, citing that there are other considerations to take into account which the internal team does not have the bandwidth for, at the time of writing.
      • They don't seem particularly applicable here, but you can never be too sure.

    Regardless, I'll take a crack at it in ~ a week, referencing @Yohannfra's changes.

  24. Yohannfra commented on May 22, 2025

    @Yohannfra
    Contributor

    This came up again in #11802. If a contributor wants to take a crack at adding a "Commit anyway" button to the error dialog, I think that'd be a great next step.

    @billygriffin Is this option still available? I'd assume so, but 2 things make me wonder:

    1. It's been 4 years, lol.
    
    2. I saw a somewhat similar PR ([Create --no-verify checkbox](https://github.com/desktop/desktop/pull/17961)) closed out, citing that there are other considerations to take into account which the internal team does not have the bandwidth for, at the time of writing.
       
       * They don't seem particularly applicable here, but you can never be too sure.
    

    Regardless, I'll take a crack at it in ~ a week, referencing @Yohannfra's changes.

    I almost forgot about this PR. It was a deal breaker for me and I moved to Sublime Merge ever since. Good luck with this PR.

  25. noerbot commented on Jul 30, 2025

    @noerbot

    FWIW I found the "Skip Hooks" option of Git Tower super useful, especially on repos with really strict/extensive pre-commit hooks.

  26. mosherc commented on Aug 26, 2025

    @mosherc

    @billygriffin and everyone else, I opened a PR according to your suggestion here, where this is only available as an option when pre-commit hooks are detected in a pre-commit hook failure specific dialog. Failures are detected by standard husky/lint-staged error messages. This may or may not work for custom implementations of pre-commit hooks and staged file linting, but should cover all off-the-shelf usage of husky and lint-staged, and varies otherwise.

  27. 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
  28. anastasiia-matiushenko commented on Feb 4, 2026

    @anastasiia-matiushenko

    if anyone already tried this feature in Github Desktop?
    I installed it and ticked "Load Git hook environment variables from shell" in Settings. but if I commit anything, there's no section like on a first screenshot above "pre-commit hook running...", just a regular commit happens

    does it work only for some specific commits?

    Image

  29. niik commented on Feb 4, 2026

    @niik
    Member

    if anyone already tried this feature in Github Desktop? I installed it and ticked "Load Git hook environment variables from shell" in Settings. but if I commit anything, there's no section like on a first screenshot above "pre-commit hook running...", just a regular commit happens

    does it work only for some specific commits?

    Hi @anastasiia-matiushenko, thanks for reaching out. Hooks support should work for all repositories with properly configured pre-commit hooks. The fact that you've got hooks support enabled and that you're not seeing the gear icon in the commit message description area tells me that GitHub Desktop doesn't believe that there's a pre-commit hook set up for your repository.

    Image

    Can you open a terminal and run ls -l .git/hooks in your JS-Fundamentals folder and paste the output here so that I can have a look at how your hooks are set up?

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

    enhancementnot-planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions