Last active
December 8, 2021 01:10
-
-
Save leogdion/677dff5ac5f8e604b04428a37f00a3fb to your computer and use it in GitHub Desktop.
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 | |
DEST_REPO=$1 | |
DEST_BRANCH=$2 | |
MESSAGE=$(git log -1 HEAD --pretty=format:%s) | |
SOURCE_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | |
git remote add destination $DEST_REPO | |
git fetch --all | |
git checkout -b destination-merging SOURCE_BRANCH | |
git reset --soft destination/$DEST_BRANCH | |
git commit -am "$MESSAGE" | |
git rebase -Xtheirs destination/$DEST_BRANCH | |
git checkout -b destination-branch destination/$DEST_BRANCH | |
git merge -Xtheirs --squash destination-merging | |
git commit -am "$MESSAGE" | |
git push destination HEAD:$DEST_BRANCH | |
git branch -D destination-branch | |
git branch -D destination-working |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment