+4 votes
1 view
in Devops and Agile by (29.9k points)
edited by

I'm new to Git, and now I'm in this situation:

I have four branches (master, b1, b2, and b3).

After I worked on b1-b3, I realized I have something to change on branch master that should be in all other branches.

I changed what I needed in master and... here is my problem:

How do I update all other branches with master branch code?

1 Answer

+4 votes
by (51.2k points)
edited by

You have two ways to resolve this problem 

Use Merge, but it creates an extra commit for merge

Alternatively, you can do a rebase.

Let’s see how this can be done: 

Checkout each branch:

git checkout b1

Then merge:

git merge origin/master

Then push:

git push origin b1

With rebase use the following commands:

git fetch

git rebase origin/master

Thus, you can update your git branch from the master. Here is an excellent tutorial for git please go through this link and you will get your basics of git more clear.

 

by (20k points)
it would be better if you use rebase rather than merge.
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...