简体   繁体   中英

Create public fork of private code, with private pushing changes to the public

I'm looking to release a public version of my personal site on Github so that people can view the source so that they can get a sense of my coding style, help to improve it or just laugh about it in my face.

The problem is, though, that I want to filter some stuff out. Of course, that means sensitive information (like db passwords and such), but also some other stuff I have running in the same codebase, but that have nothing to do with what they see on the frontend. One of the things I need to filter out is the authentication I use, both for security and licensing issues. As you can see, this belongs to this codebase, but it's not something I can release to the public.

I thought of cloning the existing git repo, change the stuff I don't want people to see and then squash all the commits together by rebasing them. However, then I can't pull any new changes from the original repo, which would keep the public repo hard to maintain.

So what would be the best way of doing this? I don't really want to rebase my original repo, I can't afford to lose the history. Or is there some other clever way I can share my source with people?

edit : to clarify, I'm using the FuelPHP framework as a base for my site. I'm trying to set things up so that the public repo is a fork of the private one. I would be developing the private source and then push to the public repo. Among database configuration files, one of the things I need to filter out is the authentication I use, both for security and licensing issues. Simple untracking the files doesn't help: you could easily revert back in to history and have the files back again

It sounds like some refactoring is in order, and this push to get your stuff on git may be just the catalyst that you need to get motivated and make sure that the things that are public are separated from the things that should be private.

First, you mentioned database passwords and other sensitive information. As an example, Wordpress keeps the database password in a separate configuration file. All users download the same copy of Wordpress, but each user generates their own wp-config.php. Consider refactoring your code so that it follows a similar model, since it's much easier to maintain 1 single disjointed file than to try to manage several.

As for the "other stuff", you weren't exactly clear on what that means exactly, but I'm assuming it refers to stuff that has absolutely nothing to do with the project or projects that you intend to share. If this is indeed the case, then maybe that "other stuff" should all be kept in a completely different project altogether. Consider moving your "other" items to a subdomain on your site so that they're actually a separate website on your server. You can even commit them to a separate repository in whatever version control system you're using.

In the end, once you've created a clear point of separation between the public world and the private one, not only will your problem be solved, but you'll also feel a bit more organized and enjoy the feeling of accomplishment in knowing you've cleaned house.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM