Managing local-only changes with git

后端 未结 3 565
野的像风
野的像风 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:02

    It's probably easier to let git do the rebase autmatically, i.e. create a local branch, configure rebase, add your changes, pull ...

    git checkout -b mybranch origin/master
    git config branch.mybranch.rebase true
    

    Adapt the Makefile to your needs ...

    git add Makefile
    git commit -m 'My local-only Makefile.'
    

    From now on git will rebase your changes upon

    git pull
    

    Alternatively, (especially if rebasing is no option for you) you can create a copy of the regular Makefile to use and gitignore:

    cp Makefile Makefile.local
    echo Makefile.local >> .git/info/exclude
    make -f Makefile.local
    

    However, with that variant you need to keep an eye on the (regular, git-controlled) Makefile and update your local version accordingly if necessary.

提交回复
热议问题