Skip to content

Cannot run pre-commit hooks in GitHub Desktop #21317

Closed

Description

@tougiTakahiro

The problem

I tried to run pre-commit hooks below.

#!/bin/sh

# コミット対象の編集された.xlsxファイルを取得
xlsx_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.xlsx$')

# .xlsxファイルがある場合はCheckSheetConflictを実行
if [ -n "$xlsx_files" ]; then
    echo "Checking sheet conflicts for: $xlsx_files"
    
    # publishディレクトリのパスを取得
    repo_root=$(git rev-parse --show-toplevel)
    
    publish_dir="$repo_root/hoge/publish/mac"
    
    # Check if publish directory exists
    if [ ! -d "$publish_dir" ]; then
        echo "Error: Publish directory not found: $publish_dir"
        exit 1
    fi
    
    executable="$publish_dir/hoge"
    
    # CheckSheetConflictを実行
    "$executable" CheckSheetConflict $xlsx_files

    # 実行結果を確認
    if [ $? -ne 0 ]; then
        echo "CheckSheetConflict failed. Commit aborted."
        exit 1
    fi
    
    echo "CheckSheetConflict passed."
fi

exit 0

When I try to commit by CLI, this hook run successfully, but by desktop, this hooks didn't run and commit passed in any situation.

"executable" contains google oauth, and googlr api access.

Release version

3.5.4

Operating system

macOS

Steps to reproduce the behavior

No response

Log files

No response

Screenshots

No response

Additional context

No response

Pinned by niik

Activity

  1. added
    triage
    on Nov 26, 2025
  2. added
    bug
    and removed
    triage
    on Nov 28, 2025
  3. 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
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions