V
V
Vova2018-06-18 11:43:49
git
Vova, 2018-06-18 11:43:49

How to move code from one branch to another?

Hello.
I have a project. It has (conditionally) three branches: a release branch, plus two branches with features.
The development process goes like this: I fix something in a feature branch, then I merger it into the release branch, and build the project.
Now it was necessary to transfer some code from one feature branch to another.
What I did:
found the required code, cut it out of feature-branch-1, committed it;
inserted the same code into feature-branch-2, committed it;
poured both branches into the release branch, corrected the conflicts.
Question two:
why does it work badly?
how to do it right?
What's bad:
a lot of conflict;
for folders, this does not work at all (that is, if I deleted the entire file from one branch, and added it to the other branch, then this will not get into the release branch at all, that is, the merge does not see this folder / file).
PS: Anticipating the question "why are you doing this": I would gladly not do this, but the management really wants me to drag the code from one branch to another.
ZZY: It is not possible to separate a specific commit in which there is code and transfer it by commit. Because the code was added little by little and mixed up (that is, non-feature code could also get into the commit).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2018-06-18
@alexey-m-ukolov

why does it work badly?
Because "non-feature code could also get into the commit" .
how to do it right?
Make atomic commits - all changes in a commit should be tightly coupled to each other, commits should be as small and frequent as possible. And do the transfer process through cherry-pick .

S
Stanislav Pugachev, 2018-06-18
@Stqs

read the docks

E
Egor Zhivagin, 2018-06-18
@Krasnodar_etc

Is it just not possible to merge one feature branch into another?
Don't make huge jumbled commits and you'll be fine (cherry-pick)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question