Last active
December 17, 2021 13:07
-
-
Save wgirhad/e9f5e52ca11a15b0ba32bd5d734320e4 to your computer and use it in GitHub Desktop.
Script to merge/push your current branch to n different branches
This file contains hidden or 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
#!/bin/bash | |
# Usage examples: | |
# merge-to master staging development | |
# merge-to master, staging, development | |
# merge-to origin/master, origin/staging, origin/development | |
current=`git rev-parse --abbrev-ref HEAD` | |
remotes=`git remote` | |
git fetch --all | |
for arg in $@ | |
do | |
branch=$arg | |
for remote in $remotes | |
do | |
branch=`echo $branch | sed -e "s|^$remote/||" -re 's/,+$//'` | |
done | |
git checkout $branch | |
git reset --hard `git rev-parse --abbrev-ref --symbolic-full-name @{u}` | |
git merge --no-edit $current | |
git push | |
done | |
git checkout $current |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment