Lets say I am on a branch test-a
and I create two new branches from a
and do some individual commits to each one(to different files in each branch):
#in branch test-a
$git checkout test-a
#creating branch test-b and push a commit
$git checkout -b test-b
$git commit -a -m "initial commit in test-b"
$git push
#creating branch test-b and push a commit
$git checkout test-a
$git checkout -b test-c
$git commit -a -m "initial commit in test-c"
$git push
Now how can I merge test-b
with test-c
in one branch, either test-b
or test-c
or in a new branch merged-b-c
branch? (not merged with test-a
)
this is the usage of merge
command in my case?:
$git checkout test-b
$git merge test-c
If you want the changes in a separate branch, then just fork out a new one from one of them, and the merge the another.
git checkout test-b
git checkout -b test-b-c
git merge test-c
Otherwise, if you don't mind updating the existing branches, the way you have merged would work too. As an additional pointer, if you are individually using the branch, and want to maintain linear history you can use rebase
too.
git checkout test-b
git rebase test-c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With