user266003
user266003

Reputation:

One project, different repositories

I have a project which I want to put into 2 repositories: public and private. The project have some private files which I don't want anyone to see that's why I have to create a private repository and those files will be in it. Likewise, I want the project to be in my portfolio, so employers will evaluate my skills easier and therofore I create a public profile as well.

So I have to use .gitignore, don't I? But is it secure enough? I think if I commit the project to the private repository, then add some files to .gitignore and commit it the public one, then those files from gitignore can be retrieved from the history, can't they? So even in the public repositore everyone can see them which is not what I want. Anyway, I have to add to and remove from gitignore those files constantly before I commit and it's redicilious.

What do I do about that?

Upvotes: 0

Views: 93

Answers (3)

String
String

Reputation: 11

We had a similar issue, and the way I handled this was to have to separate repositories completely, and use Beyond Compare to periodically sync changes. In your case, I'm assuming that the 'private' repo would be where your main development happens, and 'public' is really just a read-only repo, so you would do all of your work in 'private' and then copy changes across to 'public' using a diff tool as required.

Upvotes: 1

allonhadaya
allonhadaya

Reputation: 1297

gitignore keeps files out of version control completely, which is typically undesirable for source code.

Perhaps:

  • split your public and private code into their own repositories
  • refactor the public code into a coherent library that the private code can consume
  • establish the public repo as a subtree of the private repo like so:

git subtree add -P public_directory git://github.com/user/public-repo.git master

Upvotes: 1

chelmertz
chelmertz

Reputation: 20601

Why do you want the git repository to be public? It sounds like you want to expose the contents of the repository (the actual code), not the repository structure (the history).

If you absolutely want to expose your repository, you could use a separate branch for your private content, which you rebase on your public branch now and then. The private branch must never be pushed to any public repository. This can be a burden to manage.

Upvotes: 0

Related Questions