File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # Automatically start a rebase for all commits between HEAD and the main
4+ # branch without integrating new commits from the main branch
5+ #
6+ # Technically it's a git rebase without rebasing any commits.
7+
8+ # Enforce being in a git repository
9+ git rev-parse --is-inside-work-tree > /dev/null || exit $?
10+
11+ # We actually should check out the head branch via `git remote show ${REMOTE}`,
12+ # but this requires active connection and active 2FA verification. Tedious to
13+ # have multiple calls for this
14+ if git rev-parse --verify main & > /dev/null; then
15+ MAIN_BRANCH=main
16+ else
17+ MAIN_BRANCH=master
18+ fi
19+
20+ CURRENT_BRANCH=" $( git rev-parse --abbrev-ref HEAD) "
21+
22+ if [ " ${CURRENT_BRANCH} " = " ${MAIN_BRANCH} " ]; then
23+ echo " Cannot rebase commits from '${CURRENT_BRANCH} ' (HEAD) onto '${MAIN_BRANCH} '" >&2
24+ exit 1
25+ fi
26+
27+ MERGE_BASE=" $( git merge-base " ${MAIN_BRANCH} " HEAD) "
28+
29+ # Show the next command
30+ set -x
31+
32+ git rebase --interactive " ${MERGE_BASE} "
Original file line number Diff line number Diff line change 7777 ~/.local/bin/host-is-on : bin/host-is-on.sh
7878 ~/.local/bin/git-authors : bin/git-authors.sh
7979 ~/.local/bin/git-ard : bin/git-ard.sh
80+ ~/.local/bin/git-rewrite-commits : bin/git-rewrite-commits.sh
8081 ~/.local/bin/clean : bin/clean.sh
8182
8283# systemd
You can’t perform that action at this time.
0 commit comments