Stop git from pushing a local secret branch

Git will end up pushing every branch to remote at some point. If you have a branch that should only remain local and never be pushed, it can be singled out so that it simply cannot be pushed.

NB: This does not stop a fork of the branch from being pushed, only the specifically named branch.

git config branch.[branch not to allow].remote no_push

eg.
git config branch.8.x-1.x-local.remote no_push

The end result being something like this

# cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = https://git.drupalcode.org/project/redirect.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "8.x-1.x"]
	remote = origin
	merge = refs/heads/8.x-1.x
[branch "8.x-1.x-local"]
	remote = no_push

Tags: