Keeping track of source code variants

后端 未结 6 1747
眼角桃花
眼角桃花 2021-02-06 02:03

I am soon starting to maintain a line of products containing variants of the same embedded software. Since I\'ve been playing with git for one year and appreciate it very much,

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-06 02:47

    You should strive to, as much as possible, keep each variant's custom code in its own set of files. Then your build system (Makefile or whatever) selects which sources to use based on which variant you are building.

    The advantage to this is that when working on a particular variant, you see all of its code together, without other variants' code in there to confuse things. Readability is also much better than littering the source with #ifdef, #elif, #endif, etc.

    Branches work best when you know that in the future you will want to merge all of the code from the branch into the master branch (or other branches). It doesn't work as well for only merging some changes from branch to branch (although it can certainly be done). So keeping separate branches for each variant will probably not yield good results.

    If you use the aforementioned approach, you don't need to try to use such tricks in your version control to support your code's organization.

提交回复
热议问题