I am writing gitosis
post-push hook for central repository
which pulls updates from central repository to testing enviroment
nano /var/git/repositories/holding.git/hooks/post-update
#!/bin/bash
cd /var/vh/holding;
git reset --hard;
git checkout testing;
git pull;
here what I get after push on my client (development VM)
# blah ...
Counting objects: 57, done.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (30/30), 3.42 KiB, done.
Total 30 (delta 18), reused 0 (delta 0)
fatal: Not a git repository: '.'
fatal: Not a git repository: '.'
fatal: Not a git repository: '.'
fatal: Not a git repository: '.'
To [email protected]:holding.git
233b5a2..0f46cd8 testing -> testing
Obviously, my attempt to tell git, where it should do pull, failed.
What is correct way to run git command for a specified working copy in bash script?
As mentioned here or there, you could precede all your git commands with:
env -i
in order to make sure there is no side effect with, for instance, a GIT_DIR
environment variable which could have been previously set.
(env -i
or simply: unset GIT_DIR
)
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