Here's the setup I'm using at the moment:
HOOK 1 We will use a post-update hook on our HUB repository. So, when a push is made to the HUB by any other clone, the HOOK get’s activated and it will, according to the HEAD pointer placement, access the corresponded WORKING DIRECTORY, either on development or master, and it will from there, either: pull from hub into development branch OR pull from hub into master branch.
On ~/private/repos/projectname_hub.git/hooks
create a file named post-update
pico post-update
and place the following inside:
#!/bin/sh
echo
echo "**** Pulling changes into Dev [Hub's post-update hook]"
echo
case " $1 " in
*'refs/heads/dev'*)
cd /home/user/www/dev/ || exit
unset GIT_DIR
git pull hub dev
echo
echo "Dev was pulled"
echo
;;
esac
case " $1 " in
*'refs/heads/master'*)
cd /home/user/www/www/ || exit
unset GIT_DIR
git pull hub master
echo
echo "Master was pulled"
echo
;;
esac
exec git-update-server-info
HOOK 2 To prevent history conflicts, if we commit directly on production server for some reason, each time a prime master commit occurs, we PUSH those committed changes to the HUB.
On ~/www/www/.git/hooks
create a file named post-commit
pico post-commit
#!/bin/sh
echo
echo "**** pushing changes to Hub [Prime's post-commit hook]"
echo
git push hub
With the setup above, sometimes, I cannot precise when, we may have pushed things to the master it says "Everything is up to date" but it isn't.
Obviously all files where added and committed.
So, and after some help, we end up finding that the issue is, on the Hook setup.
I've been told to, instead of using on the post-update
hook: git pull hub master
I could use:
git fetch hub && git reset --hard hub/master
My question is:
Can anyone please provide the necessary explanation why does the git pull hub dev
works, and git pull hub master
sometimes doesn't, and how will this line help me out ?
Yes, I'm quite new on git usage, and I wish not to blind copy paste the above without at least understand. If someone could drop a few lines, it would be really appreciated.
Update:
When I do git branch -a
this is what I get:
* master
remotes/hub/dev
remotes/hub/master
Thanks in advance.