Brain Phrye

code cooking diy fiction personal photos politics reviews tools


Multiple repos

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 github.com 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:

1
2
[alias]
	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.