Skip to content

Instantly share code, notes, and snippets.

@ferreiratiago
Last active June 19, 2023 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferreiratiago/5d907c7b44ca7990b899cdafaa7157a1 to your computer and use it in GitHub Desktop.
Save ferreiratiago/5d907c7b44ca7990b899cdafaa7157a1 to your computer and use it in GitHub Desktop.
.gitconfig
[alias]
# list aliases
alias = "!git config -l | grep alias | cut -c 7-"
# one-line log
ls = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
# graph log
la = log --oneline --graph --decorate --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%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) %C(dim white)- %an%C(reset)' --all
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
u = pull
a = add
aa = add .
cm = commit -m
d = diff
co = checkout
pp = push origin HEAD
# show the working tree status in short format
s = status -s
# force (-f) remove untracked files/directories (-d) from the working tree
cf = clean -f -d
unstage = reset HEAD --
append = commit --amend --no-edit
lease = push --force-with-lease
# checkout a pull request
# usage: git pr <pull-request-id>
# example: git pr 123
# note: you will need to have the remote upstream set up for this to work
# note2: this will create a new branch named pr/<pull-request-id>
pr = "!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment