How to maintain (mostly) parallel branches with only a few difference

后端 未结 3 782
后悔当初
后悔当初 2020-12-04 15:43

Scenario: I\'m trying to get my unix dot-files under git. I have to work between (at least) the cygwin environment and some standard linux distros (ubuntu a

3条回答
  •  广开言路
    2020-12-04 16:31

    One approach is to keep a branch for each environment, plus a "master" branch that is common to all environments. Whenever you make a change to the master branch and want to pull it into another system, do something like:

    git pull
    git checkout local
    git rebase master
    

    This will rewrite the current changes on "local" (that are for this particular environment) against the current state of "master".

    The manual thing you'd need to pay attention to is where you commit a change you want to make. If it's local to a system, commit it to that system's "local" branch, else commit it to "master" and push it up to a common repository.

    Of course, rebasing may result in conflicts that you have to resolve manually. Also, if you choose to push local branches to the common repository, you'd have to (a) choose unique names for each environment, and (b) deal with the non-fast-forward pushes after rebasing. Both these problems are solvable.

提交回复
热议问题