blob: 1403ea48324d0bcb02989cc2c05e1cbef68a8001 (
plain)
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
|
# vim: ft=sh:
# Automatic branch merger (merge branch, push it to server and remove branch)
# Expects name of the branch as argument
# It fails if it's not fast forward merge and if there is fixup! commit.
gitbmerge() {
(
set -e
if [ -n "$(git log --grep="^fixup\!" HEAD.."$1")" ]; then
echo "First squash fixups!"
exit 1
fi
local WT="$(git worktree list | sed -nE "/\[$1\]/{s/([^ ]+) .*/\1/p}")"
if [ -n "$WT" ]; then
rm -r "$WT"
git worktree prune
fi
git merge --ff-only "$1" && git push && git branch -d "$1" && git push origin :"$1"
)
}
# Checkout branch to new work tree
gitbcheckout() {
local nw
nw="$(git rev-parse --show-toplevel)-$1"
git worktree add "$nw" "$1"
cd "$nw"
git submodule update --init --recursive
}
alias gitbco='gitcheckout'
# Create new branch from HEAD
gitbnew() {
git branch "$1" HEAD
gitbcheckout "$1"
}
|