-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitconfig.aliases
80 lines (79 loc) · 4.69 KB
/
gitconfig.aliases
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
#
# Include this in your own .gitconfig by using the
# [include] directive with the path to this file
#
# [include]
# path = ~/.gitconfig.aliases
#
# If you don't have any existing includes, you can add this via the following command
#
# git config --global include.path ~/.gitconfig.aliases
#
[alias]
abort = rebase --abort
aliases = "!git config -l | grep ^alias\\. | cut -c 7-"
amend = commit -a --amend
# Deletes all branches merged into the specified branch (or the default branch if no branch is specified)
bclean = "!f() { DEFAULT=$(git default); git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs -r git branch -d; }; f"
# Switches to specified branch (or the dafult branch if no branch is specified), runs git up, then runs bclean.
bdone = "!f() { DEFAULT=$(git default); git checkout ${1-$DEFAULT} && git up && git bclean ${1-$DEFAULT}; }; f"
# Lists all branches including remote branches
branches = branch -a
browse = !git open
# Lists the files with the most churn
churn = !git --no-pager log --name-only --oneline | grep -v ' ' | sort | uniq -c | sort -nr | head
cleanup = clean -xdf -e *.DotSettings* -e s3_keys.ps1
# Stages every file then creates a commit with specified message
cm = !git add -A && git commit -m
co = checkout
cob = checkout -b
# Show list of files in a conflict state.
conflicts = !git diff --name-only --diff-filter=U
cp = cherry-pick
default = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
delete = branch -d
# Discard changes to a file
discard = checkout --
ec = config --global -e
# List the changed files in the current or specified commit.
files = "!f() { git diff-tree --no-commit-id --name-only -r ${1-HEAD}; }; f"
find = "!git ls-files | grep -i"
# Force push but _only_ current branch
# See this: https://git-scm.com/docs/git-push#Documentation/git-push.txt---force for more details on the +branchname syntax
fp = "!p() { CURRENT_BRANCH=$(git branch --show-current); git push --force-with-lease --force-if-includes origin +$CURRENT_BRANCH ; }; p"
graph = log --graph -10 --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order
grep = grep -Ii
hist = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
history = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
# Shows the commit message and files changed from the latest commit
latest = "!git ll -1"
lds = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
lost = fsck --lost-found
# A better git log.
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ls-subtrees = !"git log | grep git-subtree-dir | awk '{ print $2 }'"
# Moves a set of commits from the current branch to another
migrate = "!f(){ DEFAULT=$(git default); CURRENT=$(git symbolic-ref --short HEAD); git checkout -b $1 && git branch --force $CURRENT ${3-$CURRENT@{u}} && git rebase --onto ${2-$DEFAULT} $CURRENT; }; f"
new = !git init && git symbolic-ref HEAD refs/heads/main
open = "!f(){ URL=$(git config remote.origin.url); open ${URL%.git}; }; f"
pr = "!f(){ URL=$(git config remote.origin.url); open ${URL%.git}/compare/$(git rev-parse --abbrev-ref HEAD); }; f"
publish = "!f() { git push origin $1 && git push drafts :$1 && git browse; }; f"
pushf = push --force-with-lease --force-if-includes
rba = rebase --abort
rbc = "!f(){ git add -A && git rebase --continue; }; f"
re = "!f(){ DEFAULT=$(git default); git fetch origin && git rebase origin/${1-$DEFAULT}; }; f"
remotes = remote -v
restore = "!f(){ git add -A && git commit -qm 'RESTORE SAVEPOINT'; git reset $1 --hard; }; f"
ri = "!f(){ DEFAULT=$(git default); git fetch origin && git rebase --interactive origin/${1-$DEFAULT}; }; f"
save = !git add -A && git commit -m 'SAVEPOINT'
set-origin = remote set-url origin
set-upstream = remote set-url upstream
st = status -s
stashes = stash list
sync = !git pull --rebase && git push
undo = reset HEAD~1 --mixed
# Unstage a file
unstage = reset -q HEAD --
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
wip = commit -am "WIP"
wipe = "!f() { rev=$(git rev-parse ${1-HEAD}); git add -A && git commit --allow-empty -qm 'WIPE SAVEPOINT' && git reset $rev --hard; }; f"