Here are 2 remotes, origin
and foobar
.
master
and xxxxx
master
origin is my main remote and I have local branches same as origin,
so there are master
and xxxxx
.
Sometimes I need to push xxxxx to foobar/master (not foobar/xxxxx),
by putting a command git push foobar xxxxx:master
.
But I'm afraid to push master to foobar/master by mistake.
Is there any way to prevent the master to push foobar?
Or, is there any way to allow only xxxxx to push to foobar?
Branches which belong to origin are possiblly to be incleased, and I don't want to push any other branches to foobar but only xxxxx is needed to be pushed as master to foobar.
Likely you need to set up explicit push mapping in the configuration:
git config remote.foobar.push refs/heads/xxxxx:refs/heads/master
and then use git push foobar without explicit branch specification.
Additionally you may set up pre-push hook which would validate commits being pushed.