-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliases.sh
64 lines (49 loc) · 2 KB
/
aliases.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
git config --global alias.review '!f() {
REPO=`git config remote.origin.url | sed "s/^.*:\(.*\).git/\1/"`
BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "https://www.pullreview.com/${REPO}/reviews/${BRANCH}"
}
xdg-open `f`'
git config --global alias.add-upstream 'remote add upstream'
git config --global alias.sync-master-with-upstream '!f() {
HEAD_NAME=$(cat $(git rev-parse --show-toplevel)/.git/refs/remotes/origin/HEAD | sed "s/.*\///")
git fetch upstream && git rebase upstream/$HEAD_NAME
}
f'
git config --global alias.merge-dry '!f() {
BASE_SHA=`git merge-base HEAD $1`
OUTPUT=`mktemp --suffix=.patch`
git merge-tree $BASE_SHA $1 HEAD > $OUTPUT
subl $OUTPUT
}
f'
git config --global alias.prune-branches '!f() {
UPSTREAM=$1
test -z "$UPSTREAM" && echo "Please provide an upstream." && exit 1
BRANCHES_TO_REMOVE=`git remote prune $UPSTREAM | sed "1,2d" | sed "s/ \* \[pruned\] $UPSTREAM\///"`
test -z "$BRANCHES_TO_REMOVE" && echo "No branch to prune." && exit 1
test -z "$BRANCHES_TO_REMOVE" || git branch -d $BRANCHES_TO_REMOVE | sed "s/Deleted/Pruned and deleted/"
}
f'
git config --global alias.s "status -s"
git config --global alias.lg "log --oneline --decorate --all --graph"
git config --global alias.health '!f() {
echo -n "$(basename $(pwd)) is ... fsck("
BROKEN=0
(git fsck > /dev/null 2>&1 && echo -n "OK)") || (echo -n "KO)" && BROKEN=1)
TMP_DIR=$(mktemp -d)
echo -n " clone("
(git clone -q . "${TMP_DIR}" > /dev/null 2>&1 && echo "OK)") || (echo "KO)" && BROKEN=1)
rm -R "${TMP_DIR}"
exit $BROKEN
}
f'
git config --global alias.cd "checkout"
git config --global alias.new "checkout -b"
git config --global alias.force 'push --force-with-lease'
git config --global alias.amend 'commit --amend --no-edit'
git config --global alias.boot '!git init && git commit -m "root" --allow-empty'
git config --global alias.select "add -i"
git config --global alias.root 'rev-parse --show-toplevel'
git config --global alias.conflicts 'diff --name-only --diff-filter=U'