TripTop Top
TripTop Top

Reputation: 5

merge from one branch to the other using git

i'm not good at git. I need your help here. I'm developing on two branches at the same time. I have branch 1- version_1_2, branch2-version1_3

Version 1.3 has more functionality than 1.2.

Sometimes, after bug fix, I add some changes to 1.2 and i need these changes to be on 1.3. Right now I'm doing it manually and it's not best way.

How to update the same changes from version 1.2 to 1.3(the additional functionality should remain on 1.3)

Upvotes: 0

Views: 360

Answers (2)

FelipePolido
FelipePolido

Reputation: 1

If you want to merge everything from branch version_1_2 into version_1_3 you can checkout version_1_3 and simply merge version_1_2 as answered by Tim Biegeleisen

If you just want to merge specific commits from one branch to another, without merging everything. You can use git cherry-pick:

git cherry-pick <commit-hash>

You can find the commit-hash for each of the commits from branch 1.2 by checking it out and typing: git log Another option is to use tools like gitk and gitg ( sudo apt-get install gitk gitg) to see the commit-hash.

Another option is to merge two different branches is to use graphical merging tools like git difftool or meld. Something like this would open a graphical interface for all the files that differ between the two branches:

git checkout version_1_3
git difftool version_1_2

Upvotes: 0

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522732

Since the 1.3 branch should already include all the functionality of the 1.2 branch, minus the bug fix work, an easy option here would be to merge 1.2 into 1.3:

git checkout branch-1_3    # switch to the 1.3 branch
git merge branch-1_2       # merge the 1.2 branch into 1.3

There may be merge conflicts in some files which you will have to resolve manually.

Upvotes: 1

Related Questions