Skip to content

Instantly share code, notes, and snippets.

@scrthq
Created January 25, 2019 21:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrthq/a4619ee6d5aaa7206486eb9782484394 to your computer and use it in GitHub Desktop.
Save scrthq/a4619ee6d5aaa7206486eb9782484394 to your computer and use it in GitHub Desktop.
Handy Git Aliases
# Run from PowerShell
$aliasList = @(
"a = !git add . && git status"
"aa = !git add . && git add -u . && git status"
"ac = !git add . && git commit"
"acm = !git add . && git commit -m"
"alias = !git config --get-regexp '^alias\.' | sort"
"amend = !git add -A && git commit --amend --no-edit"
"au = !git add -u . && git status"
"b = branch"
"ba = branch --all"
"c = commit"
"ca = commit --amend # careful"
"cam = commit -am"
"cm = commit -m"
"con = !git --no-pager config --list"
"conl = !git --no-pager config --local --list"
"conls = !git --no-pager config --local --list --show-origin"
"cons = !git --no-pager config --list --show-origin"
"current = !git branch | grep \* | cut -d ' ' -f2"
"d = !git --no-pager diff"
"f = fetch --all"
"fp = fetch --all --prune"
"l = log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'"
"lg = log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
"ll = log --stat --abbrev-commit"
"llg = log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit"
"master = checkout master"
"n = checkout -b"
"p = !git push"
"pf = !git push -f"
"pu = !git push -u origin ```$(git branch | grep \* | cut -d ' ' -f2)"
"s = status"
"ss = status -s"
)
foreach ($alias in $aliasList) {
$side = $alias -split " = "
Invoke-Expression $("git config --global alias.{0} `"{1}`"" -f $side[0],$side[1])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment