1

Suppose I have two branches of a Python application, threads that uses the threading module, and process that uses the multiprocessing module. These two branches differ only with respect to how they execute concurrent tasks.

Now, say I create another branch feature. How can I add the commits of feature to both threads and process, so that threads and process stay up-to-date and include the same features?

Shuzheng
  • 11,288
  • 20
  • 88
  • 186

2 Answers2

1

IF that feature branch involves files in a subfolder, then you might consider include that branch content (assuming said branch only includes the files needed for said feature) as a submodule in those two branches.

I used to do that for gh-pages branch, submodule in the master branch of a GitHub repo for instance.

But if not, if the feature branch is most of the threads or process branch files plus some modification, then you would need to merge that feature branch twice, to threads and to process branches.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thank you. I’m relatively new to Git. Is it an anti-pattern what I’m trying to do, or is it normal in development? So, to understand your answer correctly, I should merge `feature` with both `threads` and `process`. Rebasing would not be possible here for a nicer looking commit history? – Shuzheng Apr 21 '20 at 05:42
  • 1
    @Shuzheng What is not a good pattern is having two branches with only minor differences. Ideally, that difference is part of one common code, with an option set to use threads or process "mode". That way, you avoid the all "double-merge" part. – VonC Apr 21 '20 at 05:46
1

Thanks for clarifying @Shuzheng. I am writing what I understood from your question and my response after that.

What I understood from your question :

  1. I have a branch thread.
  2. I have a branch process.
  3. Now I create a new branch feature that I am going to use for development.

--> It is not clear feature branch was created from what source/base.

Here is how I would deal with this issue -

  1. Develop on feature branch and make code changes there.
  2. Once the feature is developed I would git merge branch feature into thread and process.
  3. There could be some merge-conflicts arising when I do it for the first time. But from 2nd time onwards if we maintain this process, it would be very simple 1 minute job.

This is like pulling the changes done in feature branch into other 2 branches.

Also, I would suggest to use some IDE for doing this as it makes visualization very easy during merging.

Prashant Kumar
  • 2,057
  • 2
  • 9
  • 22