Dhaval Vaghela
Dhaval Vaghela

Reputation: 450

Git: branch merge issue

I have created two branch: branch1 and branch2. i have changed one file and commit into branch1 without merge in branch2. so at this level branch2 has not that commit. now without merge branch1 into branch2, by mistakenly i commit one additional commit in branch2 .

so now i just want to this branch2 last commit changes in branch1 without losing branch1 last commit which is not available in branch2.

Is there any idea how can i solve ?

any idea helpful for me. thanks

Upvotes: 0

Views: 49

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522712

You may cherry pick the branch2 commit into branch1:

git checkout branch1
git cherry-pick <SHA-1 of branch2 commit>

But assuming that both branches have diverged from each other by only one commit, you could also just merge branch2 into branch1:

git checkout branch1
git merge branch2

This option might be less desirable if you were planning on doing a final merge from branch2 into branch1 at some later point.

Upvotes: 2

Related Questions