I have the following problem. I have updated the 'post-receive' to cd into a certain directory and then pull the repo in to deploy it like so:
#!/bin/bash
cd /var/www/site
git pull origin master
However whenever I do 'git push origin master' on my local machine I get the following:
Counting objects: 5, done.
Delta compression using up to 2 threads.
(etc..)
remote: fatal: Not a git repository: '.'
Yet when I manually cd to /var/www/site
and do git pull origin master
it works brilliantly.
Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.
As mentioned above, client-side hooks are local to any given Git repository. This means they are not cloned with the rest of the project and are not version-controlled. As such, maintaining hooks for a team can be tricky. One workaround is to store the hooks in the project directory, above the .
If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
Use unset GIT_DIR as following
#!/bin/bash
cd /var/www/site || exit
unset GIT_DIR
git pull origin master
exec git-update-server-info
You can see more information about GIT_DIR here. Git Loves the Environment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With