Skip to content

Instantly share code, notes, and snippets.

@iagoalonsomrf
Last active September 14, 2023 11:38
Show Gist options
  • Save iagoalonsomrf/f4e6e3cb1e9c1dfe3c38eaa21f11e29d to your computer and use it in GitHub Desktop.
Save iagoalonsomrf/f4e6e3cb1e9c1dfe3c38eaa21f11e29d to your computer and use it in GitHub Desktop.
Merge the default branch into yours, even if it's in a dirty state
#!/usr/bin/env bash
DEFAULT_BRANCH="master"
CURRENT_BRANCH=$(git branch --show-current)
git stash
git checkout "$DEFAULT_BRANCH"
git pull
git checkout "$CURRENT_BRANCH"
git merge "$DEFAULT_BRANCH"
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment