How to update my working Git branch from another branch (develop) ?

You just merge develop to feature1:

git checkout feature1
git merge develop

There is no need to involve another branch such as master.


First you need to update your develop branch, then checkout your feature and merge/rebase it.

git checkout develop
git pull
git checkout feature/myfeature

Now you can decide between running:

git merge develop
git rebase develop
  • merge: keeps all commits history from your branch, and that is important if your partial commits have a lot of content that can be interesting to keep.

  • rebase: Rebase means deleting the commit history from feature and instead have the history from develop; this option is obligatory in some teams.

When you are ready you can push to your own branch (for example for a pull request)

git push origin feature/myfeature

This use case is very helpful to keep updated your PR branch. Firstly, I would recommend you to fetch first your remote changes, i.e. git fetch and then merge or rebase from develop, but from the remote one, e.g.

git rebase -i origin/develop

or

git merge origin/develop

This way you will update your PR branch without going back and forth between branches.