Skip to content

GitHub desktop freezes on commit when there is a pre-commit hook #11997

Closed

Description

@Marius-Juston

Describe the bug

I added a very simple git hook that would run before every commit:

#!/bin/bash

echo "Pulling ..."
git pull

This hook is located in the .git/hooks/ folder and named pre-commit as an executable. Though when I try to commit in GitHub desktop the program freezes and does not commit.

The GitHub desktop GUI is opened using my Windows environment and I added the folder location using the \\wsl$\Ubuntu-20.04\home\... path. I am also in my GitHub enterprise account.

Version & OS

GitHub Desktop version: Version 2.7.2
Windows 10: 10.0.19042 Build 19042

The repository is located in a WSL2 environment in Ubuntu 20.04.2 LTS.

Steps to reproduce the behavior

  1. In a WSL environment create a git repository.
  2. Create a pre-commit file that run git pull
  3. In your Windows environment open GitHub desktop
  4. Select Add local repository
  5. Navigate to the WSL location of the folder (\\wsl$\Ubuntu-20.04\home\... )
  6. Commit

Expected behavior

GitHub desktop should, when I press commit just run the pre-commit script and then just commit like it normally does.

Actual behavior

GitHub desktop just freezes and has the commit sign just keep on turning.

Screenshots

image

image

Logs

2021-04-14T02:00:28.725Z - info: [ui] [AppStore] loading 9 repositories from store
2021-04-14T02:00:28.727Z - info: [ui] [AppStore] found account: Marius-Juston (Marius Juston)
2021-04-14T02:00:28.727Z - info: [ui] [AppStore] found account: mjuston2 (Juston, Marius F)
2021-04-14T02:00:30.875Z - info: [ui] launching: 2.7.2 (Windows 10.0.19042)
2021-04-14T02:00:30.876Z - info: [ui] execPath: 'C:\Users\mariu\AppData\Local\GitHubDesktop\app-2.7.2\GitHubDesktop.exe'
2021-04-14T02:00:30.892Z - info: [ui] Executing getRemotes: git remote -v (took 2.144s)
2021-04-14T02:00:30.893Z - info: [ui] Executing getRemotes: git remote -v (took 1.554s)
2021-04-14T02:00:30.928Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 1.981s)
2021-04-14T02:00:31.047Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 1.517s)
2021-04-14T02:00:31.904Z - info: [ui] Executing installGlobalLFSFilter: git lfs install --skip-repo (took 1.731s)
2021-04-14T02:00:32.080Z - info: [ui] Stats reported.
2021-04-14T02:00:32.476Z - info: [ui] Executing getCommits: git log 37852f6e0eb36f0f73da29d5bc55f1488253935a --date=raw --max-count=1 -z --format=%H%x00%h%x00%s%x00%b%x00%an <%ae> %ad%x00%cn <%ce> %cd%x00%P%x00%(trailers:unfold,only)%x00%D --no-show-signature --no-color -- (took 1.322s)
2021-04-14T02:00:34.298Z - info: [ui] Executing getBranches: git for-each-ref --format=%00%(refname)%00%(refname:short)%00%(upstream:short)%00%(objectname)%00%(author)%00%(symref)%00 refs/heads refs/remotes (took 1.710s)
2021-04-14T02:00:34.303Z - info: [ui] Executing getBranches: git for-each-ref --format=%00%(refname)%00%(refname:short)%00%(upstream:short)%00%(objectname)%00%(author)%00%(symref)%00 refs/heads refs/remotes (took 1.187s)
2021-04-14T02:00:36.733Z - info: [ui] Executing getRecentBranches: git log -g --no-abbrev-commit --pretty=oneline HEAD -n 2500 -- (took 4.120s)
2021-04-14T02:00:36.733Z - info: [ui] Executing getRecentBranches: git log -g --no-abbrev-commit --pretty=oneline HEAD -n 2500 -- (took 3.488s)
2021-04-14T02:00:40.491Z - info: [ui] Executing getCommits: git log HEAD --date=raw --max-count=100 -z --format=%H%x00%h%x00%s%x00%b%x00%an <%ae> %ad%x00%cn <%ce> %cd%x00%P%x00%(trailers:unfold,only)%x00%D --no-show-signature --no-color -- (took 1.746s)
2021-04-14T02:00:45.398Z - info: [ui] Executing getCommits: git log HEAD --date=raw --max-count=100 -z --format=%H%x00%h%x00%s%x00%b%x00%an <%ae> %ad%x00%cn <%ce> %cd%x00%P%x00%(trailers:unfold,only)%x00%D --no-show-signature --no-color -- (took 1.199s)
2021-04-14T02:00:48.291Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: mjuston2-linj2-bingyan2-austinl8 - mjuston2 (has token)
2021-04-14T02:00:50.958Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune origin (took 2.610s)
2021-04-14T02:00:58.490Z - info: [ui] [AppStore.withAuthenticatingUser] account found for repository: mjuston2 - mjuston2 (has token)
2021-04-14T02:01:04.453Z - info: [ui] Executing fetch: git -c credential.helper= fetch --progress --prune origin (took 5.957s)
2021-04-14T02:06:50.130Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 8 repositories took 12.5s of which 340.9s paused, total 353.4s
2021-04-14T02:19:00.617Z - info: [ui] [RepositoryIndicatorUpdater]: Refreshing sidebar indicators for 8 repositories took 4.0s of which 0.0s paused, total 4.0s
Pinned by niik

Activity

  1. steveward commented on Apr 14, 2021

    @steveward
    Contributor

    Thanks for the report @Marius-Juston. Have you tested out this pre-commit hook using Git from the command line to see if it works there?

    Also, are you using HTTPS or SSH authentication with this repository in WSL?

  2. added
    more-info-needed
    on Apr 14, 2021
  3. Marius-Juston commented on Apr 14, 2021

    @Marius-Juston
    Author

    I have tested out the pre-commit hook using Git from the command line and it was working.
    I believe that I was using HTTPS authentication.

  4. removed
    more-info-needed
    on Apr 14, 2021
  5. added
    investigation-needed
    on Jun 2, 2021
  6. 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

    investigation-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions