Skip to content

Instantly share code, notes, and snippets.

@damienstanton
Last active July 26, 2018 20:50
Show Gist options
  • Select an option

  • Save damienstanton/b2632c0ecd6ee268a8085401674cc7f9 to your computer and use it in GitHub Desktop.

Select an option

Save damienstanton/b2632c0ecd6ee268a8085401674cc7f9 to your computer and use it in GitHub Desktop.
Easily merge master branch onto feature branch

Let's say you are working on feature branch F, but you notice that origin/master M has been updated with commits that you want to merge onto your feature branch.

The synchronize function does this in a sensible manner.

Going from:

--*--*--*--*(M)
\--*(F)

to:

--*--*--*--*--*(F)

This allows for a cleaner history than manually fast-forwarding the master branch onto your feature.

function synchronize
git checkout master
git pull --rebase
git checkout -
git merge --no-ff master
git push
end
synchronize() {
git checkout master
git pull --rebase
git checkout -
git merge --no-ff master
git push
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment