N
N
Nikita2021-11-16 19:18:57
git
Nikita, 2021-11-16 19:18:57

How to add one commit to three branches?

There is a master branch, from which new branches are created for a particular lab. After checking the lab by the teacher, you can merge the lab-N branch with master. The situation is this: lab-0 was made and merged with master, then a lab-1 branch was created based on master, and now in the process of writing, I realized that some more changes need to be made to lab-0.
6193d6ae93ee0948535865.png

I decided to reset the lab-0 branch one commit back and make a new commit with the changes. However, now I'm not sure that this is the best solution, since now everything needs to be shifted. I made all the changes locally, I can return the "As it was" option. The idea is to simply add a new commit to master, move lab-0 to the new commit, and then rebase lab-1. Is this the right solution or is there a better way? And in general, is it worth keeping the lab-0 branch if it is already merged into master?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2021-11-16
@Casufi

The easiest way
is to make a brunch for a fix from the master, fix it, merge it into the master.
If the lab-1 franchise depends on the changes that you fixed, merge or rebase the master into the lab-1 branch, you work
If lab-1 does not depend on lab-0, then you can easily edit lab-1 and merge or rebase the master into it before merging lab-1 to the master
You don’t need to store old branches and it makes no sense to roll back the commit, edit and then think about what will happen when you merge to the master, there is no point

N
namee, 2021-12-27
@namee

git cherry-pick

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question