Let's say I have a GIT repo "MyRepo" with a subfolder "Code", like:
MyRepo
|-- .git
|-- hooks
|-- pre-commit
|-- <other stuff>
|-- Code
|-- code.java
|-- <other files>
I do cd MyRepo/Code, then make some changes, do a git commit -m "yada yada", and then the pre-commit hook runs. Only problem is that it runs in MyRepo. I want the pre-commit hook to run in the directory I'm currently in, in this case, Code. How can I achieve that?
And as an extension to this question, is there a way to make all of my git hooks behave this way?