git: how do I merge between branches while keeping some changesets exclusive to one branch?

前端 未结 9 571
情书的邮戳
情书的邮戳 2020-12-24 15:38

There\'s a special place in hell for people who hardcode absolute paths and database credentials into multiple random places in web applications. Sadly, before they go to he

9条回答
  •  别那么骄傲
    2020-12-24 16:05

    I don't know if this would work, but:

    1. Create a commit that, given the "master" version of the config files, turns them into the version you need locally. Note the SHA-1. We'll call it MAKE_LOCAL
    2. Create a commit that, given your local version of the config files, turns them into the version appropriate for master. Note the SHA-1. We'll call it MAKE_REMOTE
    3. Using git hooks, when you commit:
      1. git cherry-pick MAKE_REMOTE (or use git diff and patch)
      2. Allow the commit to commence
      3. git cherry-pick MAKE_LOCAL (or use git diff and patch)

    I think there is an even better way of transforming files in this manner, but I can't recall (if you can find shacon's git presentation from RubyConf, and can wade through 800 slides, it's in there with some great examples).

提交回复
热议问题