How to maintain (mostly) parallel branches with only a few difference

后端 未结 3 768
后悔当初
后悔当初 2020-12-04 15:43

Scenario: I\'m trying to get my unix dot-files under git. I have to work between (at least) the cygwin environment and some standard linux distros (ubuntu a

3条回答
  •  死守一世寂寞
    2020-12-04 16:40

    Good question. Even though you said:

    ...Since I don't want to checkout useless files...

    I would go for putting the platform-specific or variant-specific items in the same branch as the main code, but in a separate directory for that platform/variant. The key is to isolate the platform-specific stuff to as small an area as possible (i.e. avoid the ifdefs in the main code).

    E.g.:

    /
    +--common
    +--linux
    +--cygwin
    +--windows
    +--mac
    

    Various cross-platform projects organise themselves in this way. E.g. check out Python's source code structure for supporting multiple platforms.

    It simplifies your workflow in this regard, so you are more free to use branches for other more interesting purposes.

提交回复
热议问题