git push --all except master would also be a good start
The problem is that the refspec pattern is pretty limited.
The refspec documentation is clear:
Partial globes cannot be used in the template, so this will be unacceptable:
fetch = +refs/heads/qa*:refs/remotes/origin/qa*
However, you can use namespaces (or directories) to do something similar .
If you have a QA command that pushes a series of branches, and you want to get the master branch and any of the QA command branches, but nothing else, you can use a configuration section like this:
[remote "origin"] url = https://github.com/schacon/simplegit-progit fetch = +refs/heads/master:refs/remotes/origin/master fetch = +refs/heads/qa/*:refs/remotes/origin/qa/*
If you have a complex workflow process in which the QA team promotes branches, developers promote branches, and integration teams promote and collaborate on remote branches, you can easily use the namespace to do this.
This approach also applies to git push with remote.<name>.push entries.
Thus, the default value of git push will push only the needed refspecs ... if the excluded branches are in a separate namespace.
And this is still the whitelist approach : you need to list the branches you want to push for each namespace and leave one namespace that you don't need.
Working example:
cd /path/to/repos git init example echo test>afile git add . git commit -m "First commit in master" git checkout -b private/abranch echo abranch>>afile git add . git commit -m "First commit in a private branch" git checkout master cd .. git init --bare example.git cd example git remote add origin ../example.git git config remote.origin.push refs/heads/master:refs/remotes/origin/master
source share