Git: split the transfer request into a smaller PR based on the new directories in the extraction request

I have a monolith of a functional branch. Instead of one massive PR in the wizard, I would like to split it into 3 prs.

Ideally, I want to get some separate code from the function branch in PR myself. This code is in a new directory and has not yet been called, so it will be relatively safe PR. However, instead of just copying the catalog and creating a single commit and PR, I would like to keep the entire history of committing changes for the new PR.

Is this possible with git? I looked at the filter branch, but it looks like it's splitting the repo into two, and not to split the difference of the changes into two (if that makes sense).

+6
source share
2 answers

Github pull requests always refer to a branch. If you want to โ€œsplit the stretch requestโ€, make sure that it is well separated by latches, and then create a branch for each stretch request that you want to make, and make sure that each such branch of the function has all the corresponding commits.

It seems like a good strategy can be to create 3 branches next to your main branch, cherry - select the appropriate commits for each branch, delete them on the main one and combine the main ones with each of the three branches. Then you can have a PR for each branch and a common story.

+6
source

Is there a way to pull files from a branch, including their commit history, into a new branch?

You pull the commit, i.e. the whole repo into the branch, and not just some files.

One good option would be to reset files that you do not want to use for your preliminary content.

--x--x--x (master) \ y--y--y (branch B1 with mixed work) \ z (new branch B2, but with some files reset to master) 

B2 starts with B1 and includes the files you want with their history.
But B2 also includes other files from B1 that you would like to be as master .

You can do (in B2 ) a git reset --soft master : a git status will tell you all the changes you need to make so that your index reflects the master. Just do not add changes that are related to the files you want to save.
And do not do it. You just want to change the settings to master for some files.

(See also Practical use of git reset --soft ? ")

Once this is done, a git reset --soft B2 will return HEAD back to B2 (but with an index recording all the changes and deletes necessary to display the wizard for the correct files).

Now you can commit, and the rest of the files will return to master and the files you want intact are identical to B1 , with their history intact.

+2
source

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


All Articles