Making Git retain different section content between branches

后端 未结 4 452
难免孤独
难免孤独 2020-11-29 13:54

I\'m developing a Userscript that my employers have asked me to begin to manage via Git.

Right now, I have a stable file and a beta file, so that everyone in the org

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 14:25

    In your repository, create three files, called header.master, header.branch and main.js. Then you can keep different versions of main.js in different branches, but keep the header files the same - one for each branch, and all header files will be in all branches.

    Make a build script, called build.sh, which looks like this:

    #! /bin/sh
    cat header.$(git rev-parse --abbrev-ref HEAD) main.js >myscript.js
    

    Either users must run your build script, or you must provide the prebuilt user script yourself - but I guess you are already doing the latter, since you have a download URL!

提交回复
热议问题