Git update branch to master

Viewed 20404

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.

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.

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

Related