brst dev
brst dev

Reputation: 11

Sync a git repository with three different origins on Github/Bitbucket

Imagine I have 4 repositories: [A, B, C, D] I would like to use a simple git command to update them all at the same time.

I expect to use something like:

git push all

Any ideas?

Upvotes: 1

Views: 64

Answers (2)

Jim Redmond
Jim Redmond

Reputation: 5660

Git itself doesn't have this - its commands only ever apply to things at the repo level - but it's quite simple in bash:

for repo in a b c d; do cd ~/$repo && git push; done

Replace "a b c d" in there with the repo names or paths, and adjust the cd command accordingly. You could also wrap this in a shebang.

Upvotes: 0

Vampire
Vampire

Reputation: 38734

Just add all repos as remotes and make an alias that pushes to all of them like

git config alias.push-all '!git push remote-a && git push remote-b && git push remote-c'

Then you can use git push-all to push to all remotes. If one fails because of non-fast-forward or whatever, solve the issue and just do it again, or manually push to the remotes individually.

Upvotes: 1

Related Questions