-
Notifications
You must be signed in to change notification settings - Fork 1
Git Aliases
Austin Horstman edited this page Nov 9, 2021
·
10 revisions
a = add
ap = add -p
c = commit --verbose
co = checkout
p = push
s = status -sb
st = stash
stl = stash list
d = diff
ds = diff --stat
dc = diff --cached
rao = remote add origin
ca = commit -a --verbose
cam = commit -a -m
ac = !git add . && git commit -am
m = commit --amend --verbose
cob = checkout -b
com = checkout master
cod = checkout develop
up = !git pull --rebase --prune $@ && git submodule update --init --recursive
done = !git push origin HEAD
save = !git add -A && git commit -m 'SAVEPOINT'
wip = !git add -u && git commit -m "WIP"
undo = reset HEAD~1 --mixed
res = !git reset --hard
done = !git push -u origin HEAD
mr = push -u origin HEAD
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
rdone = "!f() { git ac \"$1\"; git done; };f"
This checks out your local master branch and deletes all local branches that have already been merged to master
brd = !sh -c \"git checkout master && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d\"
Deletes all local branches that have already been merged to the branch that you're currently on
brdhere = !sh -c \"git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d\"
pushitgood = push -u origin --all
po = !echo 'Ah push it' && git push origin && echo 'PUSH IT REAL GOOD'
mergetest = "!f(){ git merge --no-commit --no-ff \"$1\"; git merge --abort; echo \"Merge aborted\"; };f "
ria = !git rebase -i $(git merge-base HEAD master)
rid = !git rebase -i $(git merge-base HEAD develop)
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
lg = !git log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30
la = "!git config -l | grep alias | cut -c 7-"
lb = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
lbr = branch -vv
b = rev-parse --abbrev-ref HEAD
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
You have a local branch (e.g. for reviewing), but someone else did a forced push update on the remote branch. A regular git pull will fail, but this will just set the local branch to match the remote branch. BEWARE: this will overwrite any local commits you have made on this branch that haven't been pushed.
pullf = !sh -c \"git reset --hard origin/$(git rev-parse --abbrev-ref HEAD)\"
pullhead = "!f() { \
local b=${1:-$(git rev-parse --abbrev-ref HEAD)}; \
git pull origin $b; \
}; f"
smash = "!f() { \
local b=${1:-$(git rev-parse --abbrev-ref HEAD)}; \
echo 'Are you sure you want to run this? It will delete your current '$b'.'; \
read -p 'Enter to continue, ctrl-C to quit: ' response; \
git checkout master; \
git branch -D $b; \
git fetch origin $b; \
git checkout $b; \
}; f"
rbm = "!f() { \
local b=${1:-$(git rev-parse --abbrev-ref HEAD)}; \
echo 'Are you sure you want to run this? It will delete your current '$b'.'; \
read -p 'Enter to continue, ctrl-C to quit: ' response; \
git checkout master; \
git pull origin master; \
git checkout $b; \
git rebase master; \
}; f"
rbd = "!f() { \
local b=${1:-$(git rev-parse --abbrev-ref HEAD)}; \
echo 'Are you sure you want to run this? It will delete your current '$b'.'; \
read -p 'Enter to continue, ctrl-C to quit: ' response; \
git checkout develop; \
git pull origin develop; \
git checkout $b; \
git rebase develop; \
}; f"
dad = !curl https://icanhazdadjoke.com/ && echo