Managing local-only changes with git

后端 未结 3 569
野的像风
野的像风 2021-02-04 12:54

On my local branch, I have some personal (local-only) changes to a Makefile (just changing the path to the compiler). Obviously I don\'t want to commit those changes in as they

3条回答
  •  爱一瞬间的悲伤
    2021-02-04 13:16

    Why not fix the Makefile to use a variable for the path to the compiler instead of something hard-coded? Then you can just set the proper value in your environment. A lot of these (like CC for the C compiler, CPP for the C Preprocessor, etc, are pre-set by make). If yours is not, you can give it a default value that can be overridden by an environment variable. This example assume GNU make, other make utilities allow similar solutions:

    FOO ?= /usr/bin/foo
    
    test:
            @echo CC is ${CC}
            @echo FOO is ${FOO}
    

    (make sure to use real tabs).

    This gives:

    $ make
    CC is cc
    FOO is /usr/bin/foo
    $ export FOO=/opt/bin/foo
    $ make
    CC is cc
    FOO is /opt/bin/foo
    $ make FOO=/just/this/once
    CC is cc
    FOO is /just/this/once
    

    This is a much more maintainable solution, and avoids the risk of one day accidentally pushing your local-only changes upstream.

提交回复
热议问题