Brain Phrye

code cooking diy fiction personal photos politics reviews tools 

Multiple repos

[ Listen to article ]

Quite often I find it useful to push to more than one repo. If a repo is used for system configuration, I might have a central repo but also have it on the servers it’s used to manage. It can also be useful for some code review scenarios.

Since it comes up a fair bit, I have a git alias for this:

	dist = "!bash -c 'for r in $(git remote | grep -v upstream); do echo \"Pushing to $r\"; git push --all \"$r\"; git push --tags \"$r\"; done'"

When I run git dist it pushes to all my repos that don’t have upstream in their name. This handles the scenario where I’ve done a fork but still want to pull down from the upstream project but never want to push to it.