What I ended up with is: .git file structure:
.git/hooks/pre-commit.git/hooks/pre-commit-main.py
.git / Hooks / pre-commit:
#!/usr/bin/env bash export PATH="$THE_GOOD_PATH" python "$GIT_DIR/hooks/pre-commit-main.py"
.git / Hooks / pre-commit-main.py:
#!/usr/bin/env python import sys print sys.version_info
Then, when you call git commit , make sure THE_GOOD_PATH :
export THE_GOOD_PATH="$PATH" git commit
You can also export THE_GOOD_PATH="$PATH" from your .profile or top level of your application and symbolize all the bindings to a single file.
This method has the advantage of being a virtual agnostic: it also works with Ruby RVM rbenv.
I wrote to the Git developers at http://permalink.gmane.org/gmane.comp.version-control.git/258454 asking them to leave our PATH alone, but the original answer was WONTFIX.
source share