Automatically forward certain pushes to other repositories
suggest changepost-receive
hooks can be used to automatically forward incoming pushes to another repository.
$ cat .git/hooks/post-receive
#!/bin/bash
IFS=' '
while read local_ref local_sha remote_ref remote_sha
do
echo "$remote_ref" | egrep '^refs\/heads\/[A-Z]+-[0-9]+$' >/dev/null && {
ref=`echo $remote_ref | sed -e 's/^refs\/heads\///'`
echo Forwarding feature branch to other repository: $ref
git push -q --force other_repos $ref
}
done
In this example, the egrep
regexp looks for a specific branch format (here: JIRA-12345 as used to name Jira issues). You can leave this part off if you want to forward all branches, of course.
Found a mistake? Have a question or improvement idea?
Let me know.
Automatically forward certain pushes to other repositories
Table Of Contents
4 Undoing
5 Staging
6 Git diff
7 Merging
10 Submodules
11 Aliases
12 Rebasing
14 Branching
15 rev-list
16 Squashing
18 Recovering
19 git clean
21 .mailmap
23 Pulling
24 Hooks
26 Stashing
27 Subtrees
28 Renaming
29 Pushing
30 Internals
31 git-tfs
33 git-svn
34 Archive
37 Show
39 Bundles
42 Blaming
44 Worktrees
45 Git remote
47 git patch
52 TortoiseGit
57 Git rerer
59 git tagging
61 diff tree
62 Contributors