Is there a way to execute couple of git commands when I git push
to master?
What I'm having in mind is, once i did a git push
for grunt to execute:
git checkout gh-pages
git merge master
git checkout master
Is there a way to execute couple of git commands when I git push
to master?
What I'm having in mind is, once i did a git push
for grunt to execute:
git checkout gh-pages
git merge master
git checkout master
Why do you want to use Grunt to execute these commands? I think a normal shell script would suffice. Assuming you are on Linux, create an executable file called post-receive
in the .git/hooks
subdirectory, with the following contents:
#!/bin/sh
export GIT_WORK_TREE=$GIT_DIR/..
git checkout gh-pages
git merge master
git checkout master
For more information search this page for "post-receive hook".
You can do that in a post-receive hook, which would:
You have an example in "how do I deploy multiple branches to different directories via git push?", but you need to complete that script an unset GIT_DIR
, to be sure git takes into account the right non-bare repo after the cd /path/to/non/bar/repo
.