Skip to content

Instantly share code, notes, and snippets.

@janbiasi
Last active October 28, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janbiasi/eb661277df4a0e97c762 to your computer and use it in GitHub Desktop.
Save janbiasi/eb661277df4a0e97c762 to your computer and use it in GitHub Desktop.
Git Merge branch in master as overwrite
#!/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
# 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