0

There is a github project with default branch product/master owned by someone other. I want to add some feature to this project. The problem is that before I start develop this feature, I need to configure project for my hardware changing source code files (conf.h, advanced_conf.h, ...). But I don't want those configuration changes be PRed to original repo.

What way I should go to develop on some branch with changes ahead original, and after development done, exclude few commits and their changes from history?

There is a way to "remember not to add" some files every commit, but I think there must be something more effective.

How to deal with it more correctly?

  1. I create a fork repo my with same default branch my/master
  2. I create branches my/config and my/feature-dev from my/master
  3. I change some config files in my/config and commit
  4. I create a PR from my/config into my/feature-dev
  5. I develop a feature in my/feature-dev and commit many times.
  6. (?) Now I need somehow to create my/feature-release which is based on my/master, but containing commits I made to my/feature-dev excluding commits made by PR my/config=>my/feature-dev
  7. I create a PR of my/feature-release into product/master, PR is accepted, everyone is happy.

So questions are:

  • Is there a correct way doing this?
  • How to clone branch excluding some known commit ids?
filimonic
  • 3,988
  • 2
  • 19
  • 26
  • 2
    `I need to configure project for my hardware changing source code files (conf.h, advanced_conf.h, ...). But I don't want those configuration changes be PRed to original repo.` This is exactly the use case for [temporary commits](https://stackoverflow.com/a/75010635/23118). For your local use you can very well have a `config` branch but you do not need to expose it to anyone else or create a PR, just rebase `feature-dev` on top of `config` whenever you update `config`. – hlovdal Apr 19 '23 at 23:21
  • 1
    For point 6, if all your temporary commits are in your `config` branch, and `feature-dev` is rebased on top of that, then what you ask for is simply a rebase with the `--onto` argument. So when you want to create a PR run `git branch feature-release feature-dev; git rebase --onto master config feature-release; git push origin feature-release`. – hlovdal Apr 19 '23 at 23:27

0 Answers0