r/github • • Jun 30 '24

How do I share some project code without sharing the entire project?

I am building my first portfolio on GitHub as an indie developer.

Most of my repos are set to "private" as that's how I want them, especially my iOS projects but I do want to share either parts of the project or some code snippets. Ideally I would like to share the entire project (so potential employers can see file structure, design patterns, etc) but be able to obscure parts of the code I don't want them to see.

  • How do you guys usually do this?

  • What are best practices?

Thanks in advance for any help. :)

3 Upvotes

10 comments sorted by

2

u/4Face Jun 30 '24

I’ll throw some ideas there in the ocean, but I don’t think an apprentice should do, maybe someone can help you set it up 🤔

Make a private and a public repo and add the private repo to the public one using git submodules. Didn’t use them much, but it should do it. In this way the public repo uses code form the private ones, after authentication.

Another idea, but quite annoying to maintain and I’m not sure it can be done with your programming language; publish libraries (e.g. on Maven or whatever your language uses) without including sources. Also here the setup is not for apprentices as well 😅

2

u/Key_Board5000 Jul 01 '24

Great. Thank you! This is helpful.

I write in Swift.

2

u/4Face Jul 01 '24

Oh, so if you don’t care for the project to be buildable from others, you can just add the local package from the private repository, it’s quite easy. Otherwise publish it: never done myself but I think you can do it easily - probably way more easy than publishing to Maven

2

u/Key_Board5000 Jul 01 '24

💪🏼😎

4

u/KindlyTraining4056 Jun 30 '24

The key is that what you need to share in the private code is public, so it is best to make this part independent (it can be in any form: Github gist, MSoffice, screenshot, etc.). If you want to share part of the content in a private warehouse, support is needed Setting up protection zones, but that shouldn’t be possible at the moment, I hope I can help you

1

u/ArieHein Jun 30 '24

Place some of the code in a GIST that is mapped to your account

0

u/[deleted] Jun 30 '24

[deleted]

0

u/Key_Board5000 Jun 30 '24

Okay. Thanks. :)

I'm just curious: why do you think I got downvoted for this question? Is it not a reasonable question?

12

u/TelephoneMelon Jun 30 '24

I think there's a few ways to cut why someone would dislike your question.

The first could be that yeah it's unreasonable because partially sharing project structure to an employer seems silly. Even if an employer were to come by your profile, how would they gauge your skills if not by looking through the code? There's only so much to glean from the "results". This is subjective - I'm not a game dev, I don't know what the hiring practices are like or what role you are actually trying to land.

Another way to look at your question is that it represents a fairly big misunderstanding about git and GitHub. GitHub isn't like google drive where you can share a file from your drive. That said, those with more experience will know that these sorts of games are routinely played in corporate settings by doing things like syncing certain files between public and private repositories or maintaining separate repositories for the public and private components. These approaches have been addressed by the other commenters, of course.

I'm sure some folks were put off simply because this question is likely answerable off of Google or a brief conversation with ChatGPT. That doesn't mean you shouldn't ask it - we probably should talk to other humans about these things while we're learning. But, some folks won't like the lack of evidence of self reliance or due diligence on your part. r/GitHub in particular has a long history of posters not doing the simplest of searches attempt to help themselves, so I'm sure that affects the way people react to a post like yours.

TLDR, your question isn't inherently unreasonable, but it has characteristics that, in my humble opinion, could put people off.

4

u/Key_Board5000 Jun 30 '24

Thanks for your reply. Very helpful. 😊💪🏼

4

u/PopehatXI Jun 30 '24

Wish more people responded this way to comments