-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgw-config
116 lines (108 loc) · 4.75 KB
/
bgw-config
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# BerkeleyGW git configuration
# Version 0.0 - 2018/07/11
#
# Felipe H. da Jornada (2018)
#
# This file can be automatically updated with the "git update-config" command,
# which in turn can be installed with the followning command:
# curl -sL https://raw.githubusercontent.com/BerkeleyGW/git-config/master/setup.sh | sh
[core]
pager = less -R
[branch "master"]
remote = origin
rebase = true
[push]
default = simple
#[pull]
# rebase = true
[remote]
pushDefault = origin
[commit]
template = .git/commit-template
[alias]
# Core aliases
#
# Make sure there are no uncommitted and unstaged files.
# https://stackoverflow.com/questions/2657935/checking-for-a-dirty-index-or-untracked-files-with-git
is-pristine = !\
git update-index -q --refresh &&\
git diff-index --quiet --cached HEAD -- &&\
git diff-files --quiet
# Warn about untracked files.
# https://stackoverflow.com/questions/2657935/checking-for-a-dirty-index-or-untracked-files-with-git
warn-untracked = !\
git ls-files --others --exclude-standard --error-unmatch $(git rev-parse --show-toplevel) >/dev/null 2>&1 &&\
echo 'WARNING: there are untracked files in your repository' || true
# Make sure there is no WIP and that we are on the master branch
can-rebase = "!\
{ [ x$(git symbolic-ref --short -q HEAD) = xmaster ] || {\
echo 'ERROR: can only perform this operation on the master branch.' &&\
echo 'If you dont have uncommited modifications, do a \"git checkout master\".' &&\
false; }; } &&\
{ git is-pristine && git warn-untracked || {\
echo 'ERROR: index is not clean.' &&\
echo 'Please commit your modifications:' &&\
echo ' git status' &&\
echo ' git add <files you changed/added/removed>' &&\
echo ' git commit -m <brief message>' &&\
false; }; }"
# Fetch x/master and rebase master to x/master, where "x" is a generic remote.
# Accepts an optional second parameter that gets
# passed to git rebase (eg: "-i" for interactive rebase)
safe-rebase-x = "!f() { git can-rebase || return 1; \
if [ x$2 != x -a x$2 != x-i ]; then\
echo 'ERROR: unknown optional argument:' $2;\
return 1;\
fi;\
git fetch $1 && git branch -f before-rebase && git rebase $2 $1/master &&\
echo \"Success: fetched $1/master and rebased master to $1/master.\" || {\
echo \"ERROR: rebase operation of $1/master probably failed.\" &&\
echo \"Please (1) fix any conflicts, (2) type 'git rebase --continue',\" &&\
echo \"and iterate these two steps as necessary.\" &&\
echo \"You may also cancel this operation with 'git rebase --abort'.\" &&\
echo \"Your previous master branch is also saved in the temporary branch 'before-rebase'.\" &&\
echo \"You may also pass the '-i' argument to 'git sync' to perform an \" &&\
echo \"interactive rebase, and squash all but the first commit.\" &&\
false; }; }; f"
#
# TODO: add another alias, safe-rebase-squashed-x, which will first squash the
# changes introduced in master. Idea:
# mergepoint=$(git merge-base $1/master master);
# git reset --soft $mergepoint &&\
# git commit --edit -m"$(git log --format=%B --reverse master..$mergepoint)"
# https://stackoverflow.com/a/5201642
#
# Rebase origin onto master.
# Accepts an optional parameter that gets
# passed to git rebase (eg: "-i" for interactive rebase)
safe-rebase-origin = "!f() { git safe-rebase-x origin $1; }; f"
# Rebase upstream onto master
# Accepts an optional parameter that gets
# passed to git rebase (eg: "-i" for interactive rebase)
safe-rebase-upstream = "!f() { git safe-rebase-x upstream $1; }; f"
# Rebase origin onto master, then upstream
# Accepts an optional parameter that gets
# passed to git rebase (eg: "-i" for interactive rebase)
safe-rebase-all = "!f() { git safe-rebase-origin $1 && git safe-rebase-upstream $1; }; f"
# Push master branch onto origin, allowing for a history rewrite
force-push = !git push -f origin master
# This is roughly equivalent to the "svn update" command
sync = "!f() { git safe-rebase-all $1 && git force-push; }; f"
# Reinitialize the repository to point to the upstream
reinit = !\
git can-rebase && git fetch origin && git fetch upstream && \
git reset --hard upstream/master && git force-push
# Auxiliary aliases
#
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --pretty
lg = !git lg1
rev2hash = !sh -c 'git rev-list --first-parent --reverse master | awk NR==$0'
get-rev = get-abs-rev
get-abs-rev = rev-list --first-parent --count HEAD
get-rel-rev = !sh -c 'git rev-list --first-parent --count $(git rev-list --tags --max-count=1)..HEAD'
vimdiff = !git difftool --tool=vimdiff --no-prompt \"$@\"
[color]
status = auto
branch = auto
diff = auto