简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM