Skip to content

Instantly share code, notes, and snippets.

@gmmorris
Created October 16, 2019 13:03
Show Gist options
  • Save gmmorris/dc688bfd0f8e03fe7c5ffabfec4fb2cb to your computer and use it in GitHub Desktop.
Save gmmorris/dc688bfd0f8e03fe7c5ffabfec4fb2cb to your computer and use it in GitHub Desktop.
Refresh Fork's master branch from upstream and merge into the current branch
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
branch_name=${branch_name##refs/heads/}
git checkout master
git fetch upstream
git merge upstream/master
git checkout $branch_name
git merge master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment