Managing local-only changes with git

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

    There are likely several ways to approach this problem, here's my thought.

    Make a new makefix branch and commit the makefile there. Whenever you need to make the project, switch to that branch. You can work in master and just keep merging, or rebasing the makefix branch against master.

    The general idea is that you're creating a branch containing your Makefile that is never pushed.

    Personally I would rebase makefix against master so my Makefile changes always stayed ahead of the actual pushable code. It just feels cleaner in my head.

    Code Example

    git branch makefix
    git checkout makefix
    

    Make your changes to Makefile

    git add Makefile
    git commit -m "Add Local Makefile Changes to Compiler Path"
    

    For every-day work

    git checkout master
    git fetch upstream
    git merge upstream/master
    
    git checkout makefix
    git rebase master
    

    It's long and ugly, so I hope someone else has a better way =]

提交回复
热议问题