How to send multiple download requests to GitHub if they might conflict a bit

I present two independent new features for a project as pull requests. Each function is in the topic branches, each branching from the top of the wizard.

/-- feature1 master --- \-- feature2 

The problem is that although any branch can be completely merged into master by itself, when the second branch is merged, it will create conflicts. This is due not only to the fact that functions depend on each other, they simply relate to the same code.

A trivial example: if the source file was separated by commas, and each commit wanted to add one new element to it, it might look like this:

 master: a, b, c feature1: - c + c, + d feature2: - c + c, + e 

At the end of the day, if both transfer requests are accepted, and d and e must be added to the list in any order (since the functions are completely separate, so they are independent of each other). However, if you try to pull them both out, you will have a conflict.

What is the best way to handle this? Should feature2 function be based on the end of function1, and then they must be combined in the correct order in master?

 master --- \--- feature1 \------ feature2 

If I did this, would pull2 request for function2 show only function2, or would it display all functions1 + feature2?

Or do I just need to reinstall function2 after function1 is merged into master?

+4
source share
1 answer

Since none of the functions is different from the other, you should simply separate it from the master, as you would originally have. This is even though they relate to the shared file (slightly).

Then reinstall the second retrieval request (feature2) after the first (feature1) is combined with the original wizard (or call forwarding function 1 if function 2 is first combined).

 git fetch upstream git rebase upstream/master feature2 

Here we grab the commits from the upstream (the original source from which you forked), and then update our local branch function with its commits.

Then fix any merge conflicts that you may encounter and click on this commit back to your fork. The transfer request for function2 will be updated, including a commit, which eliminates a possible merge conflict and makes the merge back with the original, which is much simpler / simpler.

Or the source repository will just grab both your request request branches, and merge them yourself , fix any conflicts that may arise.

+3
source

Source: https://habr.com/ru/post/1482202/


All Articles