--- title: 'Keeping a branch up-to-date with master and then merge back the branch to master' disqus: pierodibello --- ###### tags: `git` `howto` # Keeping a branch up-to-date with master and then merge back the branch to master Assuming you already have an updated local `master` (otherwise just perform a `git pull origin master` in the `master` branch) ```shell git checkout new-feature # Go to the feature branch named "new-feature" git rebase master # Now your feature have all the commits from master! # this is because "git rebase master" reads like "git, # please rebase my commits on top on the commits from master" ``` ```shell git checkout master # Go back to master git merge --ff-only new-feature ``` (see https://shinglyu.com/web/2018/03/25/merge-pull-requests-without-merge-commits.html)