I'm looking to synchronize multiple remotes with bare copies of a git repository, such that if a developer adds or updates a branch on one remote, the changes will make it to the other remotes as well. Giving an example:
Developer A pushes the new branch "test-dev" to their origin. Developer B, (me), fetches everything from my "local" remote which corresponds to dev A's origin, and git informs me of the new test-dev branch. To manually get test-dev pushed to my "network" remote, I can either check-out the branch and then push it, or I can pass a refspec when I call git:
git push network local/test-dev:refs/heads/test-dev
The test-dev branch now shows up when someone pulls/fetches/clones from the remote I call "network". An hour later, developer A pushes some important changes to test-dev. I can then fetch and merge (or just pull) the changes, and then push the updated changes to network the same way I did before, by either having the changes checked-out, or by using a refspec.
Is there any way to automate this process? Once a new branch shows up, or changes are made to an existing branch, I'd like to have some simple command that fetches this new information from a specified remote, and then a second command that pushes it to all my other remotes. If it has to be scripted, so be it, but I'm hoping there's some parameter I can pass to an existing git command that I'm just not seeing.
Is there any way to automate this process?
Yes there is, and it's a feature of Git called hooks.
You should read the page linked here to get a feel for them, and I'll tell you that you want to implement the post-receive
hook on the server you want to use as the canonical reference for the others. If people can be pushing to multiple servers, then you'll need to implement the hook on those as well.