Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git update branch to master

I have a feature branch that I work on. Yesterday I did a commit and also merged my feature branch into the remote master branch.

Now I wish to continue working on my branch and add more functionality. However, since yesterday other people have added some additional code to the master branch. How can I "update" my feature branch so that It has all latest changes from master?

I could obviously just pull the latest version of master and simply create a new branch off of it, but I guess there is away to "update" my current feature branch.

like image 550
Kobek Avatar asked Nov 03 '17 04:11

Kobek


People also ask

How do I change branch to branch master?

First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch. So we need to be on the branch that we are merging into.


2 Answers

Yes, there has the way to update feature branch based on the latest master branch. You just need to execute the command on feature branch:

# On feature branch
git pull origin master --rebase

Now the feature branch contains the latest changes of master branch.

like image 145
Marina Liu Avatar answered Oct 13 '22 23:10

Marina Liu


Push feature branch to master

  1. Change to master branch and get latest if other developer push their feature branch to master

git checkout master

git pull

  1. Change to featurebranch and merge master to featurebranch if someone pushed their changes to master while you work on featurebranch, so that you may get conflicts to solve

git checkout hotfix

git merge --no-ff origin master

  1. Merge featurebranch to master

git checkout master

git merge --no-ff origin featurebranch

like image 34
Jinna Balu Avatar answered Oct 13 '22 23:10

Jinna Balu