This repository was archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgitconfig
More file actions
150 lines (127 loc) · 6.57 KB
/
gitconfig
File metadata and controls
150 lines (127 loc) · 6.57 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
[init]
templatedir = ~/ironcode-git-enhancements/git_template
[core]
excludesfile = ~/ironcode-git-enhancements/global-gitignore
[alias]
#########################
# BEGIN: Helper Aliases #
#########################
FeCurrentBranchName = rev-parse --abbrev-ref HEAD
FePreviousBranchName = rev-parse --symbolic-full-name --abbrev-ref @{-1}
# The first parameter ($1) is a local branch name.
FeTrackingRemoteByLocalBranchName = "!f() { git "config branch.$1.remote"; }; f"
FeTrackingBranchNameByLocalBranchName = "!f() { git "config branch.$1.merge"; }; f"
# Delete the remote branch on origin with the given branch name,
# if no branch name is given, the current branch is used.
FeDeleteRemoteBranch = "!f() { \
branch=${1-"`git FeCurrentBranchName`"}; \
git push origin --delete $branch; \
}; f"
#########################
# END: Helper Aliases #
#########################
branch-delete-merged = !git branch --merged | grep -Ev \"(^\\*|^\\s+master$)\" | xargs git branch -d
can-ff-merge = "!f() { \
: git branch ; \
[ -e "${1}" ] && echo "Missing branch name to merge" && exit 1; \
git "merge-base --is-ancestor \
$(git branch --show-current) ${1}" \
&& echo 'Yes, this can ff-merge' && exit 0 \
|| echo 'No, this can NOT ff-merge' && exit 1; \
}; f"
# Remove any branches already merged into the current branch.
# Removes any branches that have a remote that has been removed from origin.
branch-clean = !git branch --merged | grep -v '*' | xargs git branch -d && git remote prune origin
lg = log --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'
pf = push --force-with-lease
please = push --force-with-lease
cfixup = commit --fixup
csquash = commit --squash
track-origin-same-branch-name = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
current-branch = "!f() { git "rev-parse --abbrev-ref HEAD"; }; f"
# Delete all branches on remote `origin` that have been
# merged into `origin/master`
delete-merged-on-origin = !git branch --all --merged remotes/origin/master | grep --invert-match master | grep --invert-match HEAD | grep "remotes/origin/" | cut -d "/" -f 3- | xargs -n 1 git push --delete origin
# Delete previous branch.
d- = branch -d @{-1}
# Delete remote branch on origin. Optional param of branch to delete, defaults to current branch.
drb = !git FeDeleteRemoteBranch ${1}
# Delete the remote tracking branch associated with the given local branch,
# if no branch name is given, the current branch is used.
delete-remote-tracking-branch = "!f() { \
localBranch=${1-"`git FeCurrentBranchName`"}; \
\
trackingRemote=`git FeTrackingRemoteByLocalBranchName $localBranch`; \
if [[ -z $trackingRemote || '' == $trackingRemote ]]; then \
echo "There is no tracking remote to delete."; \
exit 1; \
fi; \
\
trackingBranch=`git FeTrackingBranchNameByLocalBranchName $localBranch`; \
if [[ -z $trackingBranch || '' == $trackingBranch ]]; then \
echo "There is no tracking branch to delete."; \
exit 1; \
fi; \
\
git push $trackingRemote --delete $trackingBranch; \
}; f"
# Perform reset --hard on the specified branch
# This allows us to remove the last n commits on a branch.
# @param string $1 The branch where reset --hard should be applied.
# @param string $2 The commit to be used as the new HEAD. Defaults to 'HEAD~1'.
# e.g. git reset-hard-other-branch develop HEAD~3
# performs git reset --hard HEAD~3 on branch `develop`.
reset-hard-other-branch = "!f() { \
git checkout $1; \
git reset --hard ${2:-HEAD~1}; \
git checkout @{-1}; \
}; f"
# Cherry-pick the last n commits from the last used branch ( @{-1} ).
# @param int $1 The number of commits to cherry-pick. Defaults to 1.
cherry-pick-last-n-from-last-branch = "!f() { \
git cherry-pick @{-1}~${1:-1}...@{-1}~0; \
}; f"
# Move to the given branch the last n commits.
# @param string $1 The destination branch (create if does not exist).
# @param int $2 The number of commits to move. Defaults to 1.
move = "!sh -c 'if [ -z "'$1'" ]; \
then \
echo "No destination branch supplied"; \
else \
if [ `git rev-parse --verify --quiet "'$1'"` ]; \
then \
git checkout "'$1'"; \
git cherry-pick-last-n-from-last-branch "'${2:-1}'"; \
git reset-hard-other-branch @{-1} HEAD~"'${2:-1}'"; \
else \
git checkout -b "'$1'"; \
git reset-hard-other-branch @{-1} HEAD~"'${2:-1}'"; \
fi \
fi'";
recover-rejected-commit = "!f() { git "commit -e --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG"; }; f"
open-pr-github = "!f() { \
: git branch ; \
if [[ -z $1 ]]; \
then \
target=''; \
else \
target=\"$1...\"; \
fi; \
open \"$(git ls-remote --get-url $(git config --get branch.$(git branch --show-current).remote) \
| sed 's|git@github.com:\\(.*\\)$|https://github.com/\\1|' \
| sed 's|\\.git$||'; \
)/compare/$target$(\
git config --get branch.$(git branch --show-current).merge | cut -d '/' -f 3- \
)?expand=1\"; \
}; f"
[commit]
verbose = true
[push]
# push only the current branch to the remote (and create the branch
# on the remote if it does not already exist there)
default = current
# push tags missing from remote
# See https://git-scm.com/docs/git-push#git-push---follow-tags
followTags = true
[rebase]
autosquash = true