Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does version control let you work simultaneously on two different versions of a project?

Wasn't really sure how to word the question ...

I have a project and I'd like to have a version with code for shareware registration, activation, etc. and another version without this added code (i.e., an unrestricted version).

Having created two different versions, however, I'd like to continue working on the overall project; if I update code for one version I'd like the code to be updated in the other version.

Is this possible? Is this what people mean when they talk about creating "branches"? (If the answer is "yes," then my question becomes "Is it possible to commit changes to one branch of a project and have the code simultaneously be committed to all branches?")

Thanks, as always.

like image 420
Al C Avatar asked Mar 17 '26 12:03

Al C


1 Answers

You could achieve this with source control branches, but it's probably not the best way to do it. A better way would be via conditional compilation:

void startup(void)
{
    do_some_stuff();

#ifdef RESTRICTED_VERSION
    do_check_activation();
#endif

    do_some_more_stuff();
}

Then you compile your restricted version with -DRESTRICTED_VERSION

You don't say what language you're using, but assuming it's a compiled language it's likely to have an equivalent to C's #ifdef / -D system.

like image 146
RichieHindle Avatar answered Mar 19 '26 07:03

RichieHindle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!