DEV Community

The Git Aliases That Get Me To Friday

Matt Miller on September 05, 2018

The Git Aliases That Get Me To Friday In the last few years since switching from SVN to Git, I’ve picked up a few aliases that have he...
Collapse
 
bszeliga profile image
Brandon

Nice. Here are a handful of my favorites (where we don't overlap):

# What was the last commit
last=log --name-status -1 HEAD

# History of a file
history=!git log --follow --pretty=format:"$(git config --get custom.formats.ls)" --

#Nicer logs
ls=!git log --pretty=format:"$(git config --get custom.formats.ls)" --decorate
ll=!git log --pretty=format:"$(git config --get custom.formats.ls)" --decorate --name-status
graph=!git log --graph --abbrev-commit --decorate --pretty=format:"$(git config --get custom.formats.graph)"

# My version of the alias command
la=!git config -l | grep alias | cut -c 7-

# Where am I?
where=rev-parse --abbrev-ref HEAD

# Pop off that last commit
undo=reset HEAD~1 --mixed

st=status --short

# What do I have locally that's not on the server?
out=!git log --branches="*$(git rev-parse --abbrev-ref HEAD)" --not --remotes=* --pretty=format:"$(git config --get custom.formats.ls)" --decorate

# List my formats
formats=!git config -l | grep "^custom.formats" | cut -c 16-

The formats associated with above:

[custom.formats]
    ls   = "[%C(auto,yellow)%<|(10)%h%C(reset)] [%C(auto,bold blue)%<(15trunc)%cn%C(reset)]  %C(auto)%d% C(reset)%s"
    find = "[%C(yellow)%<|(20)%h%C(reset)] [%C(bold blue)%<(10)%cn%C(reset)]  %C(auto)%d %C(reset)  %s"
    graph="%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)%n %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)"
Collapse
 
ghost profile image
Ghost

Nice. Here are my personal favorites:

alias.unstage 'reset HEAD --'
alias.append 'commit --amend --no-edit'
alias.last 'log --name-status HEAD^..HEAD'
alias.skip '!git update-index --assume-unchanged'
alias.skipped '!git ls-files -v | grep ^[a-z]'
alias.unskip '!git update-index --no-assume-unchanged'
alias.amend '!git commit --amend'
alias.issues '!f() { URL=$(git config --get remote.origin.url); open ${URL/.git}/issues/$1; }; f'
alias.undo 'reset --soft HEAD^'
alias.discard 'checkout --'
alias.review '!git diff --cached'
alias.release '!git commit -am "Release $1" && git tag -a -m $1'
alias.alias '!git config --get-regexp alias'

gist.github.com/arnaudjuracek/3188...

Collapse
 
megamattmiller profile image
Matt Miller

I'm totally stealing some of these if you don't mind :)

Collapse
 
mattkocaj profile image
matt kocaj

I use the first 4 most days gist.github.com/cottsak/413c824d93...