Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Last active January 12, 2021 14:42
Show Gist options
  • Save tbnorth/bdd95d1c104c69c788fac3879a7848d4 to your computer and use it in GitHub Desktop.
Save tbnorth/bdd95d1c104c69c788fac3879a7848d4 to your computer and use it in GitHub Desktop.
# rebase "BRANCH" onto "MAIN", change these as needed
MAIN=main
BRANCH=tmp/docs
# should be no changed files before you start
[ -z "$(git status --porcelain --untracked-files=no)" ] || echo "Changed files in repo."
git checkout "$MAIN"
git pull
git checkout "$BRANCH" # before diff in case no local branch $BRANCH
git diff "$MAIN..$BRANCH" # just to inspect
git rebase --interactive "$MAIN" # choose actions for each commit
git checkout "$MAIN"
git merge "$BRANCH"
git diff "$BRANCH..$MAIN" # should be no diffs
git push
# delete remote branch first, if it was ever pushed at all
git push -d origin "$BRANCH"
# to avoid "not fully merged" when deleting local
git branch -d "$BRANCH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment