Committing Machine Specific Configuration Files

后端 未结 10 1490
我在风中等你
我在风中等你 2020-11-22 06:43

A common scenario when I develop is that the codebase will have several config files which require machine specific settings. These files will be checked into Git and other

10条回答
  •  Happy的楠姐
    2020-11-22 07:13

    Building on @Greg Hewgill's answer, you could add a specific commit with your local changes and tag it as localchange:

    git checkout -b feature master
    vim config.local
    git add -A && git commit -m "local commit" && git tag localchange
    

    Then proceed to add your feature's commits. After finishing the work, you can merge this branch back to master without the localchange commit by doing this:

    git rebase --onto master localchange feature
    git fetch . feature:master
    git cherry-pick localchange
    git tag localchange -f
    

    These commands will:

    1) Rebase your feature branch to master, ignoring the localchange commit. 2) Fast forward master without leaving feature branch 3) Add localchange commit back to the top of the feature branch so you can continue working on it. You can do this to any other branch you want to continue working on. 4) Reset localchange tag to this cherry-picked commit so we can use rebase --onto again in the same way.

    This isn't meant to replace the accepted answer as the best general solution, but as a way of thinking out of the box about the problem. You basically avoid accidentally merging local changes to master by only rebasing from localchange to feature and fast forwarding master.

提交回复
热议问题