0

I cannot find any hook that is invoked from repository B (executes bash script on B) if I do a push from B to remote repo C. I want to take some action after push - I want to cd to another bare repo A on same machine as B is and do fetch from remote C. I can write a script wrapping git push, cd, git fetch but ideally I would like to execute cd, fetch from hook.

I am in B ( A and B are on same machine, I work in B and do push to remote C, A is tracking C so I want to cd into it and fetch/reset C into bare A)

executed in B repo:

#!bin/sh
git push
echo "updating A repository"
cd /A/project.git && git fetch origin master:master && git reset --soft

Can I put this code to some hook in B repository so it will be called automatically always after I do push to remote repository and remote repository is updated?

user229044
  • 232,980
  • 40
  • 330
  • 338
4pie0
  • 29,204
  • 9
  • 82
  • 118
  • Check out http://stackoverflow.com/questions/1797074/local-executing-hook-after-a-git-push – photoionized Apr 08 '14 at 21:46
  • well, while I don't have an instant answer for this particular question, I'd like to ask if `git new-workdir` would solve your actual problem? (`git-new-workdir` script can be found in git contribs) – user3159253 Apr 08 '14 at 21:48
  • Well, I would push not from B to C and then fetch from C to A. I would push from B to A and then from from A to C on A's `post-receive` – user3159253 Apr 08 '14 at 21:56
  • this would be OK, but A is bare repo, can I push to bare repo? – 4pie0 Apr 08 '14 at 22:10
  • why not? Bare repositories don't have working tree and thus a "current branch". Other than that it's a regular repository with all bells and wistles. – user3159253 Apr 09 '14 at 01:43

0 Answers0