Here’s the situation:
I have a public repository for my open-source app on github.com. However, now I’d like to write some specific code that will not be public (I might use it in a commercial version of my application).
I figured I could use the same repository, and I’d create a “private” branch in my git repository that I wouldn’t push.
But, mistakes happen. Is there some way to forbid git from ever pushing a branch to remote servers?
If there’s a better way to handle this situation, I would of course welcome any suggestions.
A slightly hackish solution: Make a dummy branch on GitHub with the same name as your real branch, and make sure it would not be a fast forward merge. That way, the push operation will fail.
Here’s an example.
Now that the dummy branch is set up, we can recreate it locally to diverge from the one on GitHub.
Now if we accidentally try to push, it will fail with a non-fast forward merge error: