Getting started
Committing
Browsing the history
Undoing
Staging
Git diff
Merging
Ignoring files and folders
Working with remotes
Submodules
Aliases
Rebasing
Configuration
Branching
rev-list
Squashing
Cherry picking
Recovering
git clean
.gitattributes
.mailmap
Different workflows
Pulling
Hooks
Hooks
Automatically forward certain pushes to other repositories
Verify Maven build or other build system before committing
Pre-push
Prepare-commit-msg
Post-receive
Pre-commit
Post-commit
Pre-rebase
Pre-receive
Update
Post-checkout
Local hooks
Commit-msg
Cloning repositories
Stashing
Subtrees
Renaming
Pushing
Internals
git-tfs
Empty directories in git
git-svn
Archive
Rewriting history with filter-branc
Migrating to git
Show
Resolving merge conflicts
Bundles
Display commit history graphically with gitk
Bisecting to find faulty commits
Blaming
Git revisions syntax
Worktrees
Git remote
Git large file storage
git patch
git statistics
git send-email
git gui clients
reflog - restoring commits not shown in git log
TortoiseGit
External merge and diff tools
Update object name in reference
Git branch name on Bash Ubuntu
Git client-side hooks
Git rerer
Change git repository name
git tagging
tidying up your local and remote repository
diff tree
Contributors

Automatically forward certain pushes to other repositories

suggest change

post-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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents