Answer the question
In order to leave comments, you need to log in
Merging 2 Git branches?
Hi all!
Given:
1. Git repository.
2. A project that has 2 branches:
• v2 - changes in 3 files have been made and committed. Suppose that in the first it is line 10, in the second 5, in the third 6.3. Merge conflict between master and v2.
• master - changes have been made in the same 3 files in the same lines, but they are also needed.
Answer the question
In order to leave comments, you need to log in
Correct in your case would be
1) git rebase master
from the aux branch. Probably the step involves resolving possible conflicts.
2) git rebase -i HEAD^^^
from the aux branch. We collect several secondary branch commits into one (optional, but often required for accurate commits)
3) git merge secondary-branch --ff-only
from the main branch. Fast-forward merging (that is, without resolving conflicts) new commits from the auxiliary branch
. That is, you first make changes from the main to the auxiliary branch, and then include the new commits from the auxiliary to the main branch.
Sometimes it makes sense to git rebase -i a sub branch on itself to merge a number of commits into one.
In short. It's good practice not to have merge commits on the master branch.
Alas, if git could not resolve the conflict itself, then it cannot be done automatically automatically.
You can grab only the changes you want by simply copying the v2 tree on top of the master tree and then writing only the changes you want with git add --interactive
. Anything not needed is then removed via git checkout .
, which will reset the state of the working directory to the index (anything added via git add
will remain).
everything can be done through diff
, run, compare, choose what to take and from where.
there is even a graphical shell included in TourtoisGIT
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question