Last active
August 29, 2015 14:10
-
-
Save eestrada/acb69b1d4457baa30a66 to your computer and use it in GitHub Desktop.
Useful git aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Revert a commit and then check it out as a local change. | |
# Useful if you want to revert only some of the changes from a commit. | |
# The working directory and index should already be clean first. | |
git config --global alias.revclean '!f() { git revert -n $@; git reset HEAD . ; git revert --abort; }; f()' | |
# push all references to a given remote, then fetch all updates from all remotes. | |
# This is useful if a remote has more than one push target (like an "all" remote), | |
# since other remotes that are pushed to won't update their references otherwise. | |
git config --global alias.pushfetch '!f() { git push "$1" --all; git fetch --all; }; f' | |
# useful aliases for listing logs. Taken from https://github.com/durdn/cfg/blob/master/.gitconfig | |
git config --global alias.ls 'log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative' | |
git config --global alias.ll 'log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat' | |
git config --global alias.lc '!f() { git ll "$1"^.."$1"; }; f' | |
git config --global alias.lnc 'log --pretty=format:"%h\\ %s\\ [%cn]"' | |
git config --global alias.filelog 'log -u' | |
# clean up old branches scattered across remotes and locally | |
alias.delbranch=!f() { for rmt in $(git remote); do git push "$rmt" :"${1}"; git branch -d -r "$rmt"/"${1}"; done; git branch -d "$1"; }; f | |
for br in "branch1" "branch2"; do git delbranch $br; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment