-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-rebase-default
executable file
·39 lines (29 loc) · 1.05 KB
/
git-rebase-default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Copyright (c) 2021 Benjamin Holt -- MIT License
set -e # Stop-on-error
# set -x # Uncomment for debugging
if [ "$1" == "-h" -o "$1" == "--help" ]; then
cat <<USAGE
usage: git rebase-default [REMOTE] Rebase the current branch on the
default branch of REMOTE ('origin'
by default)
git rebase-default -h|--help Print this message and exit
notes:
If the remote default branch has changed since this clone was made,
run 'git remote set-head REMOTE --auto'
config:
git config bettergit.defaultremote REMOTE Set the default remote
USAGE
exit 0
fi
Bold=`tput bold`
Off=`tput sgr0`
Remote="$1"
if [ -z "$Remote" ]; then
ConfigRemote=`git config bettergit.defaultremote || echo ""`
Remote=${ConfigRemote:-"origin"} # REM: maybe use the first remote by default? `git remote | head -n1`
fi
Other=`git symbolic-ref refs/remotes/${Remote}/HEAD | sed -e 's:^refs/remotes/::'`
echo "${Bold}Rebasing onto ${Other}${Off}"
git rebase "$Other"
###