Back

Explore Courses Blog Tutorials Interview Questions
+3 votes
2 views
in DevOps and Agile by (29.3k 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

+3 votes
by (50.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 (19.4k points)
it would be better if you use rebase rather than merge.

Browse Categories

...