-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_aliases
More file actions
30 lines (28 loc) · 1.13 KB
/
git_aliases
File metadata and controls
30 lines (28 loc) · 1.13 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
# git aliases
alias gfp="git fetch --all --tags --force --prune && git pull"
alias gs="git status -sb"
alias ga="git add"
alias gau="git add -u"
alias gc="git commit -m"
alias gp="git push"
alias gcb="git checkout -b"
# This can be configured to push by default so shouldn't be required anymore
alias gpo="git push -u origin HEAD"
alias gd="git diff"
alias glo="git log --oneline"
# Delete merged branched. Note the remote branch still needs to exist. See gtd for pruning those as well.
alias gt='git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d'
alias gcm='git checkout main'
alias gcmp='git checkout main && gfp'
gcap() {
gau
gc "$1"
gp
}
# Git TiDy - Delete branches with no remote tracking branch.
# Beware this could delete your local branch if it's not been pushed yet.
# Code from https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote
# https://stackoverflow.com/a/33548037
gtd() {
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
}