Skip to content

Instantly share code, notes, and snippets.

@peterkappus
Forked from betandr/gist:fe945e5837513cbf7c011a341417cb32
Last active July 23, 2022 17:29
Show Gist options
  • Save peterkappus/6bdaa27748b00089be8d8b9200c8896f to your computer and use it in GitHub Desktop.
Save peterkappus/6bdaa27748b00089be8d8b9200c8896f to your computer and use it in GitHub Desktop.
Handy git aliases from betandr.
[http]
proxy = http://some-proxy:80
[https]
proxy = http://some-proxy:80
[alias]
#co = checkout
#br = branch
ci = commit
st = status
co = !git checkout
br = !git branch
#edit global config
ec = !git config --global -e
#update and rebase current branch & submodules (generally do from master)
up = !git pull --rebase --prune $@ && git submodule update --init --remote --recursive
#checkout a new branch
cob = !git checkout -b
#subversion style (rarely used) commit everying
cm = !git add -A && git commit -m
#save current state as a "SAVEPOINT" commit (clean up with interactive rebase later)
save = !git add -A && git commit -m 'SAVEPOINT'
#wip = !git add -u && git commit -m WIP
#rollback last commit
undo = !git reset HEAD~1 --mixed
# fix previous commit (add more stuff (if desired) and update comments)
amend = !git commit -a --amend
#Wipes out last commit but leaves it in reflog for possible recovery
wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard
#branch clean: get all remote branches and purge local ones which have been deleted on the server
bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"
#check out master, update, and branch clean to remove any cruft
bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"
#list all branches (even remotes)
bls = !git branch -avva
#update the origin for this repo (e.g. if the name has changed)
bup = !git remote update origin --prune
#push new branch to origin
pushus = !git push --set-upstream origin
#if you're using a mirror, push to it via this alias
pushmi = !git push --mirror
#remove local version of a single file (or files) (pass in name of file to remove)
rmc = !git rm -r --cached
# nicely formatted log
ll = !git log --pretty=oneline --abbrev-commit
#print all the aliases from this file. So meta.
alias = !git config --list | grep alias | sed s/^alias\\.//g | sed s/=\\!/\\ =\\ /g
[user]
email = email.address@somewhere.com
name = My Name...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment