David Semeria
David Semeria

Reputation: 542

Force git to push different branches to different repos

Let's say I have two local branches: master & dev. I want to force all pushes on the master branch to a repo called master and all pushes on dev to different one called dev.

Why? Because I want to maintain two continuous integration environments, one for each repo.

What I really want to do is make sure the master repo rejects all branches other than master and vice-versa. It's fundamental that I don't inadvertently push the wrong branch to the wrong repo.

Any ideas?

Upvotes: 2

Views: 55

Answers (1)

murraybo
murraybo

Reputation: 973

Use

git branch dev --set-upstream dev/dev

to define the default upstream location.

This will not fully guard you but if you use "push" without parameter it should go to the right remote branch.

Avoid pushing with "+" or --force could help too. If the server uses something like gitolite do not grant the "+" privilege to you user. This would deny non fast-forward pushes.

Upvotes: 1

Related Questions