You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
post checkout hook gives error when using desktop app, but fine in cmd line #3067
This is an interesting side-effect of how we bundle Git in the app, and I needed to cast my mind back to this classic post.
Under the section "WHY WON’T GIT HOOKS WORK ON WINDOWS?", we have this section:
On Unix-like OS’s, the #! tells the program loader that this is a script to be interpreted, and /bin/sh is the path to the interpreter you want to use, sh in this case. Windows is definitely not a Unix-like OS. Git for Windows supports Bash commands and shell scripts via Cygwin. By default, what does it find when it looks for sh.exe at /bin/sh? Yup, nothing; nothing at all.
What's the fix?
Fix it by providing the path to the sh executable on your system.
As a workaround, these scripts can directly reference your Git installation, like so:
#!C:/Program\ Files/Git/usr/bin/sh.exe
That will work for you, but it's not an actual solution. Git for Windows doesn't set any other environment variables than the path to git.exe, so it might have some magic internals we need to mimic when we invoke Git inside the app (our version of Git is limited in features, but it does have sh.exe).
Those hooks are likely written by LFS, so it's possible that it could be taught to write the correct #! line. I'm not sure how feasible it is to figure out that it should use #!C:/Program\ Files/Git/usr/bin/sh.exe, without asking users to configure it manually. Any suggestions?
@technoweenie nah, I wouldn't worry about a fix for this in Git LFS right now. Imagine a scenario where we only have Desktop installed - Git will live under %LOCALAPPDATA% at a version-specific location, and I can think of a few ways this is going to make your life hell.
We'll teach our Git to be smarter about this, as that's much more malleable (and our responsibility ultimately).
We can't support bash.exe scripts on Windows currently because it's not part of the Git installation we embed, but /bin/sh support should work once I get desktop/dugite#141 merged and updated here.
Activity
shiftkey commentedon Oct 17, 2017
This is an interesting side-effect of how we bundle Git in the app, and I needed to cast my mind back to this classic post.
Under the section "WHY WON’T GIT HOOKS WORK ON WINDOWS?", we have this section:
What's the fix?
As a workaround, these scripts can directly reference your Git installation, like so:
That will work for you, but it's not an actual solution. Git for Windows doesn't set any other environment variables than the path to
git.exe, so it might have some magic internals we need to mimic when we invoke Git inside the app (our version of Git is limited in features, but it does havesh.exe).MrAntix commentedon Oct 17, 2017
The work around does work for me, but not for my colleague, who doesn't have a C: drive
For now we can manage this, thanks for the explanation.
technoweenie commentedon Oct 17, 2017
Those hooks are likely written by LFS, so it's possible that it could be taught to write the correct
#!line. I'm not sure how feasible it is to figure out that it should use#!C:/Program\ Files/Git/usr/bin/sh.exe, without asking users to configure it manually. Any suggestions?shiftkey commentedon Oct 17, 2017
@technoweenie nah, I wouldn't worry about a fix for this in Git LFS right now. Imagine a scenario where we only have Desktop installed - Git will live under %LOCALAPPDATA% at a version-specific location, and I can think of a few ways this is going to make your life hell.
We'll teach our Git to be smarter about this, as that's much more malleable (and our responsibility ultimately).
shiftkey commentedon Oct 30, 2017
We can't support
bash.exescripts on Windows currently because it's not part of the Git installation we embed, but/bin/shsupport should work once I get desktop/dugite#141 merged and updated here.