Last active
October 28, 2020 09:54
-
-
Save janbiasi/eb661277df4a0e97c762 to your computer and use it in GitHub Desktop.
Git Merge branch in master as overwrite
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
#!/bin/sh | |
TARGET="master" | |
BRANCH="seotweaks" | |
git push origin $TARGET && git stash | |
# Overwrite $TARGET with $BRANCH | |
git checkout $BRANCH | |
git merge -s ours $TARGET | |
git checkout $TARGET | |
git merge $BRANCH | |
# Delete branch locally and on origin | |
git branch -d $BRANCH | |
git push origin :$BRANCH |
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
# Move repo-1 into repo-2 while keeping the history | |
git clone repo1 | |
git clone repo2 | |
cd repo2 | |
git remote add repo1 ../repo1 | |
git pull repo1 master --allow-unrelated-histories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment