Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: how can I exclude just one branch from push?

I'd like to continue to push (almost) all branches with a simple git push command, but there are a few things I'd like to be able to keep in Git locally without sharing them with the rest of the world.

The things I'm keeping locally include private changes to public files—hence, I'd like to keep the secret stuff in an appropriately named branch that doesn't get pushed to the server. Is this a thing?

like image 231
Eris Avatar asked Dec 28 '22 14:12

Eris


1 Answers

Just create branches in some namespace like private - git checkout -b private/mybranch. As long as that namespace is not existing on the remote repo, any branch in that namespace will not be pushed when you do git push

To also prevent pushing by explicit, set the branch.<name>.remote to some some nonexistent remote.

like image 98
manojlds Avatar answered Jan 11 '23 09:01

manojlds