Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using git as version control for a lot of my projects which apart from source code have a number of reports and sensitive documents.

All my repos are currently private but I wish to make some of them public. As mentioned above, I wish to hide some of the files (or may be directories) from public. Is that even possible? If not, is there a better way of doing this?

share|improve this question
Git stores repository state as a single unit (the commit). It is not possible to hide a part of a commit. – grawity Mar 2 '13 at 21:51
up vote 1 down vote accepted

Hiding specific information in a git repository is not one of the things it's designed for. AFAIK it is also not possible. One approach that might work, though I have never tried this, is to have a public and a private git repo, and have the private repo be a git submodule for the public one. This might be more hassle then it's worth though, and might be confusing at points causing you to put private data in the public repo. So perhaps you should just have tow completely separate repos.

share|improve this answer
Ok cool. If it's not possible; then well it's not possible. Thanks. – p0lAris Mar 2 '13 at 21:56
Ok. So I'll have private repos — but say for example I change some files in private that are also part of public — how would I commit changes to both the public and private repos together? – p0lAris Mar 2 '13 at 22:00
It would be odd to have dependencies going from the public repo to the private repo. If people can't use certain parts of the public one without having access to the private one, there is little point in having these be public no? I'd try to keep all dependencies in the other direction. At least that is my reaction as software developer, though I suspect this applies just as well to documents in general. – Jeroen De Dauw Mar 2 '13 at 22:03
@flippex17: You can't do that. If you think about it, what could it possibly do with the commit message? – David Schwartz Mar 2 '13 at 22:06
@Jeron — what I meant was. Consider I have some header and implementation files that are the same in both public and private repositories. But I add a method in to one of the header and implementation files in the private repo — how would I duplicate those changes in the public one. Sorry if I sound confused. – p0lAris Mar 2 '13 at 22:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.