Skip to content

Instantly share code, notes, and snippets.

@amaddio
Created October 19, 2023 09:15
Show Gist options
  • Save amaddio/e53cdccbe5c489d0d7f6dfced3d7f440 to your computer and use it in GitHub Desktop.
Save amaddio/e53cdccbe5c489d0d7f6dfced3d7f440 to your computer and use it in GitHub Desktop.
Rebase the (currently checked out) feature branch on top of the latest tip of the remote main branch
# git fetch: get the latest reference pointer of the remote
# --all: all branches
# --prune: delete local branches that were deleted on the remote
# git branch -vvv | grep main: show the offset of commits between local and remote's `main` branch
# git branch -vvv | grep $(git branch --show-current): show the offset of commits between local and remote's branch, that is checked-out.
# git rebase --autostash origin/main: rebase the (commits of the) current branch on top of the `main` branch
git fetch --all --prune && git branch -vvv | grep main && git branch -vvv | grep $(git branch --show-current) && git rebase --autostash origin/main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment