blob: 3bbdefa21b7d8188d4bd6f83fe4497a6397f1516 (
plain) (
blame)
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
|
#function git_current_branch() {
#local ref
#ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
#local ret=$?
#if [[ $ret != 0 ]]; then
#[[ $ret == 128 ]] && return # no git repo.
#ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
#fi
#echo ${ref#refs/heads/}
#}
# reset-origin a2_develop
reset-origin() {
if [[ -z $(git status -s) ]];
then
currentBranch="$(git rev-parse --abbrev-ref HEAD)";
branch="$1";
git checkout $branch &&
git pull &&
git reset --hard origin/production &&
git push -u origin $branch -f &&
git checkout $currentBranch;
else
echo "Your branch is dirty. Stash or commit changed before proceeding";
fi
}
# Git aliases
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gco='git checkout'
alias gb='git branch'
alias gc='git commit -v'
alias gcm='git commit -v -m'
alias gc!='git commit -v --amend'
alias gst='git status'
alias gd='git diff'
alias gl='git log'
alias gp='git push'
alias gr='git rebase'
alias gri='git rebase -i'
alias grm='git rebase -i origin/master'
alias grc='git rebase --continue'
grename() {
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 old_branch new_branch"
return 1
fi
# Rename branch locally
git branch -m "$1" "$2"
# Rename branch in origin remote
if git push origin :"$1"; then
git push --set-upstream origin "$2"
fi
}
g_most_edited() {
git log --pretty=format: --name-only "$@" | \
sort | \
uniq -c | \
sort -rg | \
grep -E -v '.(html|scss|json)$' | \
head -n 10 \
;
}
|