Last active
February 26, 2024 01:17
-
-
Save Magnus167/c593f9c36c5a6397d7561d530a058124 to your computer and use it in GitHub Desktop.
git pmerge - pull & merge. Use with Windows (powershell) or Unix-like alike
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# git checkout featureX | |
# git pmerge main | |
# When merging branch `main` into `featureX`, | |
# one often has to pull from `main` to ensure | |
# merging into the correct head. | |
# Assume you're on branch featureX | |
# >> git pmerge main | |
# executes: | |
# >> BRANCH=$(git branch --show-current) # BRANCH is featureX | |
# >> git checkout main | |
# >> git pull | |
# >> git checkout BRANCH | |
# >> git merge main | |
git config --global alias.pmerge '!f() { BRANCH=$(git branch --show-current); git checkout "$1" && git pull && git checkout "$BRANCH" && git merge "$1"; }; f' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment