Skip to content

24 ways to impress your friends

Keeping Parts of Your Codebase Private on GitHub


Comments are ordered by helpfulness, as indicated by you. Help us pick out the gems and discourage asshattery by voting on notable comments.

Got something to add? You can leave a comment below.


Wouldn’t it be easier and cleaner to use git submodules, and keep the private parts inside a submodule that lives as a private git repo? That way it’s easier to differentiate what’s public and what isn’t, and it’s also migrateable, so you wouldn’t need to add the private remote manually if you clone the repo on a new machine.

Robert Lee-Cann

I’d be fearful of using this technique; It would only take an accidental pre-caffeine “git push origin dev”, and the dev branch gets pushed to public!

I know you can easily “git push origin :dev” to delete the remote branch afterwards, but the damage could already be done.


Thank you,
I have a quest.
first I had a master branch, then I made my private branch and I added some files or modified some files that are also in the master branch.
now I want to revert all the modified files in the private branch to the version of master branch , but keep the added files in this private branch.
every thing local, but im supposed to just push the private branch.
would you please help me? thank you.


David Hund

First off: thanks Harry: great to learn of these Github workarounds!

I love Github but I use Bitbucket too. I would use Bitbucket a lot more, however, if it would support Pages like Github does: with a personal domainname.

At the moment Bitbucket does not support CNAME’s and unfortunately they seem not too keen to support this soon:


Couple of things.

First, as someone mentioned BitBucket is, IMO, at par or better than GitHub in terms of features. The fact that you can have unlimited private repos alone is enough a reason to migrate over. I understand that people like GitHub because it’s so popular, but you are missing out by not looking at BitBucket or other competitors.

Second, the problem is that GitHub is not supposed to be a CMS, even though some people want to use it as such. Use GitHub as a project/source base, have its website completely separate. You have to do so much git judo because you are trying to use it for something it wasn’t meant for.

Impress us

Be friendly / use Textile